An .xlsx workbook, as cells.
An open package holds the file's parts still compressed, knows which sheets it has and where they are, and has read the two tables a cell needs to make sense of itself: the shared strings and the styles. Its sheets are not read until something asks for one.
That last part matters. A workbook's cells are spread across one part per
sheet, and reading them all is the one cost that grows with the file: the
zip work is flat, but the XML is not. memory/1 reads them all; a workbook
over the file, through Sheetshow.Workbook.xlsx/2, reads only the tabs a
plan or a range names.
{:ok, package} = Sheetshow.Xlsx.open(File.read!("costs.xlsx"))
Sheetshow.Xlsx.titles(package)
["Costs", "log"]A cell's value is what was entered, as everywhere else in Sheetshow: a
formula reads back as a formula, with what the workbook last worked it out to
in meta.effective. Nothing here evaluates anything, so that cached answer is
only as fresh as the program that wrote the file, which is what
Sheetshow.Backend.supports?(workbook, :evaluates_formulas) says out loud.
This module is the read side of the codec. Writing goes through
Sheetshow.Workbook.xlsx/2 and Sheetshow.run/2, which rewrite one tab of
the file and copy everything else across untouched.
Summary
Types
An open workbook: its zip entries, its workbook part, and the two tables a cell needs to make sense of itself: the shared strings and the styles.
Functions
Opens a package and reads every sheet, in one call.
Same as decode/1, raising on failure.
Every sheet, as a Sheetshow.Memory: the whole workbook in the shape the
rest of the library already runs ops against and reads cells out of.
Opens a package: its parts, its sheets, its shared strings and its styles. Reads no worksheet.
The sheet titles, sorted, as every titles/1 in Sheetshow answers.
Types
@opaque t()
An open workbook: its zip entries, its workbook part, and the two tables a cell needs to make sense of itself: the shared strings and the styles.
Opaque, and the fields are term() here for the same reason: every one of
them is an xlsx internal this library does not promise anything about. Make
one with open/1 and hand it back to the functions here.
Functions
@spec decode(binary()) :: {:ok, Sheetshow.Memory.t()} | {:error, Sheetshow.Error.t()}
Opens a package and reads every sheet, in one call.
{:ok, memory} = Sheetshow.Xlsx.decode(File.read!("costs.xlsx"))
Sheetshow.Memory.titles(memory)
["Costs", "log"]
@spec decode!(binary()) :: Sheetshow.Memory.t()
Same as decode/1, raising on failure.
@spec memory(t()) :: {:ok, Sheetshow.Memory.t()} | {:error, Sheetshow.Error.t()}
Every sheet, as a Sheetshow.Memory: the whole workbook in the shape the
rest of the library already runs ops against and reads cells out of.
This is the read that grows with the file. A workbook over the file reads one tab at a time instead.
@spec open(binary()) :: {:ok, t()} | {:error, Sheetshow.Error.t()}
Opens a package: its parts, its sheets, its shared strings and its styles. Reads no worksheet.
A workbook with no shared strings and no styles is ordinary, since one writer puts its text in the cells rather than in a table, so neither being there is not an error.
The sheet titles, sorted, as every titles/1 in Sheetshow answers.