pub struct Workbook {Show 24 fields
pub sheets: Vec<Arc<Sheet>>,
pub names: Vec<DefinedName>,
pub styles: StyleTable,
pub theme: Theme,
pub date_system: DateSystem,
pub calc: CalcSettings,
pub show_objects: ShowObjects,
pub remove_personal_info: bool,
pub active_sheet: ActiveSheet,
pub view: WorkbookView,
pub props: DocProps,
pub protected_structure: bool,
pub structure_password: Option<PasswordHash>,
pub custom_lists: Vec<Vec<String>>,
pub cell_styles: Vec<(String, Style)>,
pub phonetics: Vec<PhoneticString>,
pub vba_project: Option<Arc<Vec<u8>>>,
pub csv_delimiter: Option<u8>,
pub macros: Macros,
pub macros_read: Vec<Value>,
pub macros_unread: Arc<Vec<Value>>,
pub preserved: Option<Arc<Preserved>>,
pub source_dir: Option<PathBuf>,
pub source_path: Option<PathBuf>,
}Fields§
§sheets: Vec<Arc<Sheet>>§names: Vec<DefinedName>§styles: StyleTable§theme: Theme§date_system: DateSystem§calc: CalcSettings§show_objects: ShowObjects§remove_personal_info: boolTrust Center › Privacy Options › “Remove personal information from file properties on save”
(<workbookPr filterPrivacy="1"/>): kept with the file, and while it is on the author and
company are left out of the XLSX files GridCraft writes, as Excel leaves them empty. Other
formats aren’t filtered: the workbook’s own serialization still holds them.
active_sheet: ActiveSheetRead and set with Workbook::active_sheet and Workbook::set_active_sheet.
view: WorkbookViewThe workbook window’s display settings (<workbookView>), kept across an open + save.
props: DocProps§protected_structure: boolWorkbook structure protection.
structure_password: Option<PasswordHash>Password of the structure protection (XLSX workbookProtection), never the password.
custom_lists: Vec<Vec<String>>Custom fill lists (Options › Custom Lists) beyond the built-in ones.
cell_styles: Vec<(String, Style)>Named cell styles (Cell Styles gallery): name → style.
phonetics: Vec<PhoneticString>Phonetic (furigana) data of shared strings (xl/sharedStrings.xml), one entry per string
text, so that an open + save keeps a Japanese workbook’s readings. Written back next to the
<si> holding the same text.
Keyed by text because that is all a cell keeps of its shared string: the saved table holds
each text once (the format’s uniqueCount), so two <si> items that share a base text can
only keep one reading — the reader keeps the first and warns. Empty for workbooks without
phonetic data; not present in older JSON. Modelled data (unlike Workbook::preserved,
which holds unmodelled parts), so it is saved to JSON as well as to XLSX.
vba_project: Option<Arc<Vec<u8>>>VBA project (xl/vbaProject.bin) carried through unchanged. GridCraft does not run
macros; the blob is preserved so that saving a macro-enabled workbook never destroys the
macros it arrived with. base64 in JSON. None = the workbook has no macros. Shared, so a
copy of the workbook (every edit’s undo step) doesn’t copy it.
csv_delimiter: Option<u8>Field separator of the CSV this workbook was read from, so saving it as CSV writes the same
separator back (a ; file stays a ; file). None = not read from CSV: CSV saves use ,.
macros: MacrosGridCraft macros (typed command lists, not VBA), in the order the macro list shows them. The JSON format keeps them as this field; xlsx keeps them in hidden defined names.
macros_read: Vec<Value>The macros entries of a JSON file as read, before the engine checks each one on its own
and moves it into macros, so one damaged or newer macro doesn’t stop the file opening.
Never written.
macros_unread: Arc<Vec<Value>>Macros in a newer format than this build reads, as the file held them. They are never read, listed or run; a save writes them back unchanged, so the newer build gets them back whole. Shared between snapshots, as nothing changes them.
preserved: Option<Arc<Preserved>>Unmodelled file content kept for saving (package root and workbook level). Not in JSON.
source_dir: Option<PathBuf>The folder the workbook was read from, which relative paths to linked workbooks in
preserved are relative to. Saving into another folder rewrites them from there. Not in JSON.
source_path: Option<PathBuf>The file this workbook reports as its own, which is what CELL("filename") returns.
None = no file yet, which Excel reports as an empty string until the workbook has been
saved once. Deliberately separate from source_dir: that one names the folder relative
links are relative to and must keep naming it after a Save As into another folder, since
the links in memory are still written for the old one. Not in JSON.
Implementations§
Source§impl Workbook
impl Workbook
pub fn sheet(&self, i: usize) -> Option<&Sheet>
pub fn sheet_mut(&mut self, i: usize) -> Option<&mut Sheet>
pub fn sheet_index(&self, name: &str) -> Option<usize>
Sourcepub fn active_sheet(&self) -> usize
pub fn active_sheet(&self) -> usize
The index of the sheet the workbook’s window shows (the file’s active tab).
Sourcepub fn set_active_sheet(&self, i: usize)
pub fn set_active_sheet(&self, i: usize)
Changes the active sheet in place, also through a shared Arc<Workbook>: it is view state,
so switching sheets or windows neither copies the workbook nor makes it a new version.
pub fn active(&self) -> Option<&Sheet>
Sourcepub fn next_sheet_name(&self) -> String
pub fn next_sheet_name(&self) -> String
A fresh sheet name SheetN not in use.
Sourcepub fn check_sheet_name(
&self,
name: &str,
except: Option<usize>,
) -> Result<(), String>
pub fn check_sheet_name( &self, name: &str, except: Option<usize>, ) -> Result<(), String>
Validates a sheet name like Excel: 1–31 chars, none of : \ / ? * [ ], not starting or
ending with ', unique (case-insensitive) unless it is except’s own name.
Sourcepub fn name(&self, name: &str, sheet: usize) -> Option<&DefinedName>
pub fn name(&self, name: &str, sheet: usize) -> Option<&DefinedName>
Finds a defined name visible from sheet: sheet scope first, then workbook scope.
Sourcepub fn name_call_case(&self, e: Expr) -> Expr
pub fn name_call_case(&self, e: Expr) -> Expr
Spells calls of LAMBDA names the way the names are defined (Double(4), where the
parser gives DOUBLE(4): it upper-cases function names, as built-in ones are shown).
Sourcepub fn apply_name_call_case(&mut self)
pub fn apply_name_call_case(&mut self)
Workbook::name_call_case for every cell formula and defined name (after reading a
file).
Sourcepub fn table(&self, name: &str) -> Option<(usize, usize)>
pub fn table(&self, name: &str) -> Option<(usize, usize)>
Table by name across sheets: (sheet index, table index).
Sourcepub fn refresh_equations(&mut self)
pub fn refresh_equations(&mut self)
Rebuilds the cached layout of every equation whose source changed (or was never laid
out, as after loading a file). One call lays out at most MAX_EQUATION_LAYOUT_BYTES of
source: one equation can take a tenth of a second to lay out, so a file with thousands of
them would otherwise hold the app for minutes. Equations past the budget get an error
instead (they show their source; editing one lays it out).
Sourcepub fn next_object_id(&self) -> u32
pub fn next_object_id(&self) -> u32
A free id for a new chart, picture, shape, table, slicer or form control: one more than the largest in
use, or, when that is u32::MAX (a file can carry any id), the lowest free one.
Sourcepub fn free_object_ids(&self, count: usize) -> Vec<u32>
pub fn free_object_ids(&self, count: usize) -> Vec<u32>
count distinct ids no object in the workbook uses, sorted: the ones above the largest id
in use while they last, then the lowest free ones. Fewer come back only when the id space
is exhausted.