pub struct Sheet {
pub id: u64,
pub name: String,
pub tables: Vec<ExcelTable>,
pub dependencies: HashMap<Dependency, HashSet<CellRef>>,
pub dependencies_rev: HashMap<CellRef, HashSet<Dependency>>,
pub uncommitted_actions: Vec<SheetAction>,
pub locale: Locale,
/* private fields */
}Expand description
A worksheet
Fields§
§id: u64Workbook-unique identifier
name: StringDisplay name, as it appears in a cross-sheet reference.
tables: Vec<ExcelTable>Excel Tables (ListObjects) defined on this sheet.
dependencies: HashMap<Dependency, HashSet<CellRef>>Forward edges: which cells must be recomputed when a dependency changes
dependencies_rev: HashMap<CellRef, HashSet<Dependency>>Reverse edges: what each cell currently reads, so its old edges can be dropped when its formula changes
uncommitted_actions: Vec<SheetAction>Edits made since the last commit, for callers that want to observe or replay them.
locale: LocaleRegional locale for date and number parsing.
Implementations§
Source§impl Sheet
impl Sheet
Sourcepub fn get_result_data(&self, cell: &CellRef) -> ResultData
pub fn get_result_data(&self, cell: &CellRef) -> ResultData
The computed value of a cell, or ResultData::None if it is empty
or outside the sheet’s allocated grid.
Sourcepub fn get_display_string(&self, cell: &CellRef) -> String
pub fn get_display_string(&self, cell: &CellRef) -> String
Interpolate the cell’s value into a string, with a specified cell format
Sourcepub fn get_cell_type(&self, cell: &CellRef) -> CellType
pub fn get_cell_type(&self, cell: &CellRef) -> CellType
Returns the intrinsic data type of a cell.
Sourcepub fn set_cell_type(&mut self, row: usize, col: usize, cell_type: CellType)
pub fn set_cell_type(&mut self, row: usize, col: usize, cell_type: CellType)
Sets the intrinsic data type of a cell at (row, col).
Sourcepub fn set_cell_with_type(
&mut self,
row: usize,
col: usize,
src: String,
cell_type: CellType,
)
pub fn set_cell_with_type( &mut self, row: usize, col: usize, src: String, cell_type: CellType, )
Sets the source text and explicit cell type of a particular cell.
Sourcepub fn set_cell_src(&mut self, row: usize, col: usize, src: String)
pub fn set_cell_src(&mut self, row: usize, col: usize, src: String)
Directly sets the src of a cell and marks it dirty.
Does not automatically evaluate it.
Call Sheet::commit to evaluate
updated cells.
Sourcepub fn insert(&mut self, pos: TextCellRef, input: &str)
pub fn insert(&mut self, pos: TextCellRef, input: &str)
Inserts text into a cell’s source at a character offset, as typing into it would, then recompiles and marks it dirty.
Sourcepub fn delete_one_before(&mut self, pos: TextCellRef)
pub fn delete_one_before(&mut self, pos: TextCellRef)
Delete one before (like backspace)
Sourcepub fn delete(&mut self, start: TextCellRef, end: TextCellRef)
pub fn delete(&mut self, start: TextCellRef, end: TextCellRef)
Deletes the text between two positions, recompiling and dirtying every cell it touches.
Sourcepub fn extend(&mut self, direction: Direction)
pub fn extend(&mut self, direction: Direction)
Grows the sheet by one empty row or column on the given side.
Sourcepub fn ensure_capacity(&mut self, target_row: usize, target_col: usize)
pub fn ensure_capacity(&mut self, target_row: usize, target_col: usize)
Ensure sheet has at least target_row+1 rows and target_col+1 columns
Sourcepub fn get_cell_style(&self, row: usize, col: usize) -> Option<&CellStyle>
pub fn get_cell_style(&self, row: usize, col: usize) -> Option<&CellStyle>
The style set on a cell, or None if it has none.
Sourcepub fn set_cell_style(&mut self, row: usize, col: usize, style: CellStyle)
pub fn set_cell_style(&mut self, row: usize, col: usize, style: CellStyle)
Replaces a cell’s style, growing the sheet if the cell is past its current bounds
Sourcepub fn update_cell_style<F>(&mut self, row: usize, col: usize, f: F)
pub fn update_cell_style<F>(&mut self, row: usize, col: usize, f: F)
Mutates a cell’s style in place.
Grows the sheet if needed; a style left empty is dropped.
Sourcepub fn clear_cell_style(&mut self, row: usize, col: usize)
pub fn clear_cell_style(&mut self, row: usize, col: usize)
Removes a cell’s style
Sourcepub fn get_column_width(&self, col: usize) -> Option<f64>
pub fn get_column_width(&self, col: usize) -> Option<f64>
Returns the custom width for the zero-based column, if one is set.
Sourcepub fn set_column_width(&mut self, col: usize, width: Option<f64>)
pub fn set_column_width(&mut self, col: usize, width: Option<f64>)
Sets or clears the custom width for an existing zero-based column.
Sourcepub fn get_row_height(&self, row: usize) -> Option<f64>
pub fn get_row_height(&self, row: usize) -> Option<f64>
Returns the custom height for the zero-based row, if one is set.
Sourcepub fn set_row_height(&mut self, row: usize, height: Option<f64>)
pub fn set_row_height(&mut self, row: usize, height: Option<f64>)
Sets or clears the custom height for an existing zero-based row.
Sourcepub fn insert_row(&mut self, index: usize)
pub fn insert_row(&mut self, index: usize)
Insert a new empty row at the specified index. If index is >= row_count, appends at the end
Sourcepub fn delete_row(&mut self, index: usize)
pub fn delete_row(&mut self, index: usize)
Deletes a row, shifting the rows below it up.
Sourcepub fn insert_cells_shift_down(
&mut self,
row: usize,
first_col: usize,
last_col: usize,
count: usize,
)
pub fn insert_cells_shift_down( &mut self, row: usize, first_col: usize, last_col: usize, count: usize, )
Excel’s Insert cells, shift down over an inclusive column band.
Sourcepub fn delete_cells_shift_up(
&mut self,
row: usize,
first_col: usize,
last_col: usize,
count: usize,
)
pub fn delete_cells_shift_up( &mut self, row: usize, first_col: usize, last_col: usize, count: usize, )
Excel’s Delete cells, shift up over an inclusive column band; the
inverse of Sheet::insert_cells_shift_down.
Sourcepub fn delete_col(&mut self, index: usize)
pub fn delete_col(&mut self, index: usize)
Deletes a column, shifting the columns to its right left.
Sourcepub fn insert_col(&mut self, index: usize)
pub fn insert_col(&mut self, index: usize)
Insert a new empty column at the specified index If index is >= columns.len(), appends at the end
Sourcepub fn columns(&self) -> &[DataColumn]
pub fn columns(&self) -> &[DataColumn]
The sheet’s columns
Source§impl Sheet
impl Sheet
Sourcepub fn new(args: SheetInit) -> Sheet
pub fn new(args: SheetInit) -> Sheet
Creates a sheet of args.rows x args.cols empty cells, every one of
them queued as a pending edit so the first Sheet::commit sees them.
Sourcepub fn setup_after_deserialization(&mut self)
pub fn setup_after_deserialization(&mut self)
Rebuilds what serialization drops.
Sourcepub fn mark_all_dirty(&mut self)
pub fn mark_all_dirty(&mut self)
Queues every cell for recomputation on the next Sheet::commit.
Sourcepub fn commit(
&mut self,
context: Option<&Context<'_>>,
) -> Result<HashSet<CellRef>, EngineError>
pub fn commit( &mut self, context: Option<&Context<'_>>, ) -> Result<HashSet<CellRef>, EngineError>
Commit all changed src items with a context for sheet lookups
Sourcepub fn eval_with_row(
&self,
input: &str,
context: Option<&Context<'_>>,
row: Option<usize>,
col: Option<usize>,
) -> Result<(ResultData, Vec<Dependency>), EngineError>
pub fn eval_with_row( &self, input: &str, context: Option<&Context<'_>>, row: Option<usize>, col: Option<usize>, ) -> Result<(ResultData, Vec<Dependency>), EngineError>
Evaluates cell source text without storing it, as
Sheet::eval does, but from the point of view of (row, col).
Sourcepub fn eval(
&self,
input: &str,
context: Option<&Context<'_>>,
) -> Result<(ResultData, Vec<Dependency>), EngineError>
pub fn eval( &self, input: &str, context: Option<&Context<'_>>, ) -> Result<(ResultData, Vec<Dependency>), EngineError>
Evaluates cell source text against this sheet without storing it, returning the value and the references it read.
Sourcepub fn get_src(&self, cell: &CellRef) -> Option<&String>
pub fn get_src(&self, cell: &CellRef) -> Option<&String>
The raw text typed into a cell. Returns None if ref is OOB
Sourcepub fn get_src_str(&self, cell: &CellRef) -> String
pub fn get_src_str(&self, cell: &CellRef) -> String
Sheet::get_src but returns empty string on OOB.
Sourcepub fn get_src_str_ref(&self, cell: &CellRef) -> Option<&str>
pub fn get_src_str_ref(&self, cell: &CellRef) -> Option<&str>
Sheet::get_src as a borrowed &str for read-only.
Source§impl Sheet
impl Sheet
Sourcepub fn find_table(&self, name: &str) -> Option<&ExcelTable>
pub fn find_table(&self, name: &str) -> Option<&ExcelTable>
Finds a table on this sheet by name, matched case-insensitively as Excel does.
Sourcepub fn find_table_mut(&mut self, name: &str) -> Option<&mut ExcelTable>
pub fn find_table_mut(&mut self, name: &str) -> Option<&mut ExcelTable>
Sheet::find_table, mutably.
Sourcepub fn add_table(
&mut self,
name: String,
start_row: usize,
start_col: usize,
end_row: usize,
end_col: usize,
has_header_row: bool,
has_totals_row: bool,
) -> Result<u64, String>
pub fn add_table( &mut self, name: String, start_row: usize, start_col: usize, end_row: usize, end_col: usize, has_header_row: bool, has_totals_row: bool, ) -> Result<u64, String>
Defines a new Excel Table over the rectangular range
start_row..=end_row x start_col..=end_col (0-based, inclusive)
on this sheet.
Sourcepub fn delete_table_by_name(&mut self, name: &str) -> Result<(), String>
pub fn delete_table_by_name(&mut self, name: &str) -> Result<(), String>
Removes a table definition from this sheet, leaving the cells it covered untouched.
§Errors
Returns a message if no table on this sheet has that name.
Sourcepub fn rename_table(
&mut self,
old_name: &str,
new_name: &str,
) -> Result<(), String>
pub fn rename_table( &mut self, old_name: &str, new_name: &str, ) -> Result<(), String>
Renames a table on this sheet.
Renaming here does not rewrite the formulas that reference the table.
WorkbookManager::rename_table handles that.