Expand description
Opening and saving files: XLSX, legacy XLS import, XLSB and ODS data import, SYLK import, CSV/TSV, JSON (debug), HTML export.
Enums§
- File
Kind - File formats GridCraft reads or writes.
Constants§
- DECRYPTED_
NOTICE - The first open warning of a workbook decrypted with its password.
- MAX_
ADOPTED_ RESULT_ CELLS - The most result cells
adopt_pythonrebuilds from a file’s cached spills, over all its Python cells (each one is also limited tocrate::model::python::MAX_RESULT_CELLS). - PASSWORD_
REQUIRED - The error for an encrypted workbook opened without a password contains this. The interface
asks for the password when it sees it; programmatic callers pass
passwordinstead. - WRONG_
PASSWORD - The error for a wrong password contains this.
Functions§
- adopt_
python - Python cells from a file: a cell whose formula is
PY("…",0|1)(a format that kept it as a formula) becomes a Python cell, and a Python cell whose spilled values the file cached gets them back as its result, so it shows them until it runs again. Results are rebuilt for at mostMAX_ADOPTED_RESULT_CELLScells in all; the rest keep only their own cached value, and the values they spilled stay as plain values. Returns the warnings. - base64_
decode - base64_
encode - csv_
values_ bytes - The active sheet as CSV of raw cell values, for automation: numbers at full precision, dates and
times as ISO 8601, booleans
TRUE/FALSE, errors as their text, text as stored. Save As CSV writes displayed text instead (save_bytes) and stays the default. - enforce_
python_ limits - A file is somebody else’s work: a Python cell whose code doesn’t fit in Excel’s
8,192-character formula keeps only its cached value, and a kept result that is not a
well-formed array of at most
crate::model::python::MAX_RESULT_CELLScells is dropped (the cell keeps its value). Either way the values the cell spilled stay as plain values (crate::model::Sheet::settle_spill). Returns the warnings. - image_
size - Pixel size of a PNG or JPEG from its header.
- open_
bytes - Parses a file’s bytes into a workbook.
namepicks the format by extension when the bytes don’t say. An encrypted workbook needsopen_bytes_with_password. - open_
bytes_ with open_bytes_with_password, and withcsv_as_texta CSV/TSV/TXT file keeps every field as the text it holds, with no number, date or boolean conversion (identifiers such as GTINs, SKUs and ZIP codes survive). It does not apply to other formats.- open_
bytes_ with_ password open_bytes, first decrypting a password-protected workbook withpassword. Errors never quote the password.- read_
file - save_
bytes - Encodes a workbook in the format chosen by
path’s extension. - save_
bytes_ as - Encodes a workbook as
kind, whateverpath’s extension says. - save_
file_ bytes save_bytesfor the file atpath: relative paths to linked workbooks are rewritten for its folder, so they still name the same files.- source_
dir - The folder of the file at
path, which relative paths to linked workbooks are relative to. - source_
path - The file at
pathasCELL("filename")reports it: absolute, so the folder is the one the user sees. A workbook that arrived as bytes has no path and keeps only its name. - to_html
- A sheet as a standalone HTML table (Save as Web Page). A sheet with pictures gets the sheet’s own column widths and row heights so each picture and chart (inline SVG) can sit at its anchor.
- write_
file