Skip to main content

Module io

Module io 

Source
Expand description

Opening and saving files: XLSX, legacy XLS import, XLSB and ODS data import, SYLK import, CSV/TSV, JSON (debug), HTML export.

Enums§

FileKind
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_python rebuilds from a file’s cached spills, over all its Python cells (each one is also limited to crate::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 password instead.
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 most MAX_ADOPTED_RESULT_CELLS cells 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_CELLS cells 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. name picks the format by extension when the bytes don’t say. An encrypted workbook needs open_bytes_with_password.
open_bytes_with
open_bytes_with_password, and with csv_as_text a 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 with password. 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, whatever path’s extension says.
save_file_bytes
save_bytes for the file at path: 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 path as CELL("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