Expand description
GridCraft file formats: XLSX (transitional and strict) and CSV import/export, plus XLSB and ODS data import
and legacy Excel 97-2003 .xls (BIFF8) import, and password-encrypted workbooks (Agile and Standard encryption).
Clean-room implementation from ECMA-376 / ISO/IEC 29500 and observed behaviour. All entry points work on byte slices (no file system access), so the crate builds for WebAssembly.
Reading is lenient: unsupported or broken optional parts are skipped and reported in
ReadReport::warnings; only a missing/invalid package or workbook part is an error. Hostile
input is bounded: decompressed parts are capped at 512 MB (1 GB per package), cells outside
Excel’s grid are dropped and XML nesting is limited.
Structs§
- CsvOptions
- CSV import options.
- Read
Report - What a lenient read skipped or repaired.
Enums§
- Decrypt
Error - Why an encrypted workbook couldn’t be decrypted.
- Format
- A file format guessed from content.
- IoError
- Errors from reading or writing files.
- Xlsx
Kind - Which member of the SpreadsheetML family a package is saved as. Only the content type of the workbook part differs (ECMA-376 Part 1 Workbook part; MS-OI29500 adds the macro-enabled types).
Constants§
- MAX_
CSV_ BYTES - The largest CSV or tab-separated file written (bytes).
- MAX_
PART - Largest decompressed part accepted.
Functions§
- check_
encryption - Whether the right password could decrypt this encrypted workbook, checked without one. An error names a scheme no password opens (RC4, rights management…) or damage, so callers can say so instead of asking for a password first.
- decode_
text - Decodes CSV bytes with BOM-aware UTF-8 and UTF-16 handling. Without a BOM, valid UTF-8 is kept.
Other bytes decode as Windows-1256 when they read as Arabic (see [
Cp1256Evidence]), else as Windows-1252. - decrypt
- The plain OOXML package (a zip) inside an encrypted workbook.
- oversized_
part - The part of a zip package that declares more than
MAX_PARTunpacked bytes, with that size: what anIoError::TooLargefrom reading the package is about when one part is too large. - read_
csv - read_
csv_ with_ report read_csv, with the warnings an open shows: a column whose date order had to be guessed, or whose dates stayed text because it holds both orders.- read_
ods - Imports ODS sheets, typed values, displayed text and merges. Cached formula results are imported as constants, so editing their inputs does not recalculate the original formula. Always inspect the returned warnings. Saving to ODS is not supported.
- read_
xls - Reads an Excel 97-2003 workbook. Inspect the report’s warnings for what was skipped.
- read_
xlsb - Imports worksheet scalar values and saved formula results. Number formats are omitted; dates remain serial numbers with the workbook’s original date system. Inspect warnings.
- read_
xlsx - Reads an
.xlsx/.xlsm/.xltx/.xltmpackage (the workbook part is found through the package relationships, so every main-part content type is accepted). - read_
xlsx_ with read_xlsx, and opens formulas from Google Sheets’ XLSX export as the formulas written in Google Sheets (#2871).- rebase_
links wbas it is saved into the folderto(absolute): the relative paths of its linked workbooks, relative to the folder it was read from, are rewritten relative toto, as Excel does on Save As, or made absolute when no relative path exists (another drive).Nonewhen nothing changes.- sniff
- Guesses the format from content: ODS mimetype, XLSB package content types, other ZIP packages as XLSX, text as CSV.
- write_
csv - Writes the sheet as CSV from A1 to the end of its used range, so leading empty columns and rows
stay as empty fields and every cell keeps its position (CRLF line ends, UTF-8 without BOM).
cell_textgives each cell’s field text: the caller decides how values look (Save As CSV writes them as displayed, number formats applied); quoting is done here. - write_
csv_ limited write_csvwith the output caplimit(bytes) given.- write_
xlsx - Writes a workbook as an
.xlsxpackage, or as an.xlsmone when it holds a VBA project. - write_
xlsx_ as - Writes a workbook as the given member of the
.xlsxfamily. - write_
xlsx_ named - Writes a workbook as the given member of the
.xlsxfamily for the filebook_name(a bare file name, used for the workbook in a PivotChart’s link to its PivotTable).