# `Exceed.Worksheet.Cell`
[🔗](https://github.com/synchronal/exceed/blob/main/lib/exceed/worksheet/cell.ex#L1)

A protocol for transforming source data into data structures that can be streamed
to appropriate SpreadsheetML tags, using the `XmlStream` library.

This protocol is implemented for floats, integers, strings, and binaries, in addition
to `Date`, `DateTime`, and `NaiveDateTime`. If the [decimal](https://hex.pm/packages/decimal)
library is present, this protocoal is automatically implemented for `Decimal`.

## Examples

``` elixir
defimpl Exceed.Worksheet.Cell, for: MyStruct do
  alias XmlStream, as: Xs

  def to_attrs(%MyStruct{value: value}) when is_binary(value),
    do: %{"t" => "inlineStr"}

  def to_content(%MyStruct{value: value}) when is_binary(value),
    do: Xs.element("is", [Xs.element("t", [Xs.content(value)])])
end
```

# `t`

```elixir
@type t() :: term()
```

All the types that implement this protocol.

# `to_attrs`

```elixir
@spec to_attrs(t()) :: XmlStream.attrs()
```

For a given data type, these attributes will be merged onto the `c` tag wrapping
this cell's content. Note that the `r` attribute (designating the cell's identifier
in `A1` format) will be calculated when streaming a worksheet to XLSX, and should
_not_ be included in this output.

# `to_content`

```elixir
@spec to_content(t()) :: XmlStream.fragment()
```

For a given data type, convert the value to a list of tags. Functions from
`XmlStream` including `XmlStream.element/3`, `XmlStream.empty_element/2`, and
`XmlStream.content/1` may be used to facilitate the generation of tags.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
