Parser and surgical mutator for xl/worksheets/sheet*.xml.
Two sets of operations are exposed:
- Binary-in / binary-out (
parse/1,put_cell/3,merge/3,unmerge/2,merged_ranges/1) — convenient for one-off use but each pays the cost of a fullSaxy.SimpleFormparse and re-emit. - Tree-in / tree-out (
parse_tree/1,encode_tree/1,put_cell_in_tree/3,merge_in_tree/3,unmerge_in_tree/2,merged_ranges_from_tree/1,cells_from_tree/1) — used byExVEx.Workbookto cache the parsed tree across many mutations and serialize only once atExVEx.save/2time. This is what keeps bulk writes fast.
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
@type coordinate() :: ExVEx.Utils.Coordinate.t()
@type t() :: %ExVEx.OOXML.Worksheet{ cells: %{required(coordinate()) => ExVEx.OOXML.Worksheet.Cell.t()} }
Functions
@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.
@spec merge_in_tree(tree(), ExVEx.Utils.Range.t(), boolean()) :: tree()
@spec merged_ranges(binary()) :: {:ok, [ExVEx.Utils.Range.t()]} | {:error, term()}
Reads the existing <mergeCells> list from a worksheet XML document.
@spec merged_ranges_from_tree(tree()) :: [ExVEx.Utils.Range.t()]
@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.
@spec put_cell_in_tree(tree(), coordinate(), ExVEx.cell_value()) :: tree()
@spec unmerge(binary(), ExVEx.Utils.Range.t()) :: {:ok, binary()} | {:error, term()}
Removes a merged range from the worksheet.
@spec unmerge_in_tree(tree(), ExVEx.Utils.Range.t()) :: tree()