ExVEx.OOXML.Worksheet (ExVEx v0.1.3)

Copy Markdown View Source

Parser and surgical mutator for xl/worksheets/sheet*.xml.

Two sets of operations are exposed:

Surrounding worksheet elements (<sheetViews>, <cols>, <pageMargins>, etc.) are not modeled; they pass through the SimpleForm round-trip unchanged.

Summary

Functions

Adds a merged range to the worksheet. When clear_non_anchor? is true, every cell in the range other than the anchor (top-left) is removed from <sheetData> — Excel's visible convention.

Reads the existing <mergeCells> list from a worksheet XML document.

Surgically applies a cell mutation to a worksheet's raw XML and returns the new XML. Unrelated cells, rows, and surrounding worksheet content are preserved at the element level.

Removes a merged range from the worksheet.

Types

coordinate()

@type coordinate() :: ExVEx.Utils.Coordinate.t()

t()

@type t() :: %ExVEx.OOXML.Worksheet{
  cells: %{required(coordinate()) => ExVEx.OOXML.Worksheet.Cell.t()}
}

tree()

@type tree() :: {String.t(), list(), list()}

Functions

cells_from_tree(arg)

@spec cells_from_tree(tree()) :: t()

encode_tree(tree)

@spec encode_tree(tree()) :: binary()

merge(xml, range, clear_non_anchor?)

@spec merge(binary(), ExVEx.Utils.Range.t(), boolean()) ::
  {:ok, binary()} | {:error, term()}

Adds a merged range to the worksheet. When clear_non_anchor? is true, every cell in the range other than the anchor (top-left) is removed from <sheetData> — Excel's visible convention.

merge_in_tree(arg, range, clear_non_anchor?)

@spec merge_in_tree(tree(), ExVEx.Utils.Range.t(), boolean()) :: tree()

merged_ranges(xml)

@spec merged_ranges(binary()) :: {:ok, [ExVEx.Utils.Range.t()]} | {:error, term()}

Reads the existing <mergeCells> list from a worksheet XML document.

merged_ranges_from_tree(arg)

@spec merged_ranges_from_tree(tree()) :: [ExVEx.Utils.Range.t()]

parse(xml)

@spec parse(binary()) :: {:ok, t()} | {:error, term()}

parse_tree(xml)

@spec parse_tree(binary()) :: {:ok, tree()} | {:error, term()}

put_cell(xml, coordinate, value)

@spec put_cell(binary(), coordinate(), ExVEx.cell_value()) ::
  {:ok, binary()} | {:error, term()}

Surgically applies a cell mutation to a worksheet's raw XML and returns the new XML. Unrelated cells, rows, and surrounding worksheet content are preserved at the element level.

Passing nil for value clears the cell.

put_cell_in_tree(arg, coordinate, value)

@spec put_cell_in_tree(tree(), coordinate(), ExVEx.cell_value()) :: tree()

unmerge(xml, range)

@spec unmerge(binary(), ExVEx.Utils.Range.t()) :: {:ok, binary()} | {:error, term()}

Removes a merged range from the worksheet.

unmerge_in_tree(arg, range)

@spec unmerge_in_tree(tree(), ExVEx.Utils.Range.t()) :: tree()