View Source Exceed.Worksheet.Cell protocol (Exceed v0.6.2)
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
library is present, this protocoal is automatically implemented for Decimal
.
Examples
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
Summary
Functions
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.
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.
Types
@type t() :: term()
All the types that implement this protocol.
Functions
@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.
@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.