View Source Exceed.Worksheet.Cell protocol (Exceed v0.3.0)

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

Types

t()

All the types that implement this protocol.

Functions

For a given data type, these attributes will be merged onto the c tag wrapping this cell's content.

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.

@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.