Skip to main content

Sheet

Struct Sheet 

Source
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: u64

Workbook-unique identifier

§name: String

Display 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: Locale

Regional locale for date and number parsing.

Implementations§

Source§

impl Sheet

Source

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.

Source

pub fn get_display_string(&self, cell: &CellRef) -> String

Interpolate the cell’s value into a string, with a specified cell format

Source

pub fn get_cell_type(&self, cell: &CellRef) -> CellType

Returns the intrinsic data type of a cell.

Source

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).

Source

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.

Source

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.

Source

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.

Source

pub fn delete_one_before(&mut self, pos: TextCellRef)

Delete one before (like backspace)

Source

pub fn delete(&mut self, start: TextCellRef, end: TextCellRef)

Deletes the text between two positions, recompiling and dirtying every cell it touches.

Source

pub fn extend(&mut self, direction: Direction)

Grows the sheet by one empty row or column on the given side.

Source

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

Source

pub fn get_cell_style(&self, row: usize, col: usize) -> Option<&CellStyle>

The style set on a cell, or None if it has none.

Source

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

Source

pub fn update_cell_style<F>(&mut self, row: usize, col: usize, f: F)
where F: FnOnce(&mut CellStyle),

Mutates a cell’s style in place.

Grows the sheet if needed; a style left empty is dropped.

Source

pub fn clear_cell_style(&mut self, row: usize, col: usize)

Removes a cell’s style

Source

pub fn get_column_width(&self, col: usize) -> Option<f64>

Returns the custom width for the zero-based column, if one is set.

Source

pub fn set_column_width(&mut self, col: usize, width: Option<f64>)

Sets or clears the custom width for an existing zero-based column.

Source

pub fn get_row_height(&self, row: usize) -> Option<f64>

Returns the custom height for the zero-based row, if one is set.

Source

pub fn set_row_height(&mut self, row: usize, height: Option<f64>)

Sets or clears the custom height for an existing zero-based row.

Source

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

Source

pub fn delete_row(&mut self, index: usize)

Deletes a row, shifting the rows below it up.

Source

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.

Source

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.

Source

pub fn delete_col(&mut self, index: usize)

Deletes a column, shifting the columns to its right left.

Source

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

Source

pub fn columns(&self) -> &[DataColumn]

The sheet’s columns

Source

pub fn row_count(&self) -> usize

Allocated rows

Source

pub fn col_count(&self) -> usize

Allocated columns

Source§

impl Sheet

Source

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.

Source

pub fn setup_after_deserialization(&mut self)

Rebuilds what serialization drops.

Source

pub fn mark_all_dirty(&mut self)

Queues every cell for recomputation on the next Sheet::commit.

Source

pub fn commit( &mut self, context: Option<&Context<'_>>, ) -> Result<HashSet<CellRef>, EngineError>

Commit all changed src items with a context for sheet lookups

Source

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).

Source

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.

Source

pub fn get_src(&self, cell: &CellRef) -> Option<&String>

The raw text typed into a cell. Returns None if ref is OOB

Source

pub fn get_src_str(&self, cell: &CellRef) -> String

Sheet::get_src but returns empty string on OOB.

Source

pub fn get_src_str_ref(&self, cell: &CellRef) -> Option<&str>

Sheet::get_src as a borrowed &str for read-only.

Source

pub fn get_word_boundaries( &self, cell: &CellRef, char_offset: usize, ) -> (usize, usize)

Source§

impl Sheet

Source

pub fn find_table(&self, name: &str) -> Option<&ExcelTable>

Finds a table on this sheet by name, matched case-insensitively as Excel does.

Source

pub fn find_table_mut(&mut self, name: &str) -> Option<&mut ExcelTable>

Source

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.

Source

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.

Source

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.

Source

pub fn resize_table( &mut self, name: &str, new_end_row: usize, new_end_col: usize, ) -> Result<(), String>

Extends or shrinks a table’s range by moving its bottom-right corner to new_end_row/new_end_col (the top-left corner never moves).

Source

pub fn rename_table_column( &mut self, table_name: &str, col_index: usize, new_name: &str, ) -> Result<(), String>

Renames one column (0-based, relative to the table) of a table, updating both its stored name and the header row’s cell text (if the table has one).

Trait Implementations§

Source§

impl Clone for Sheet

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Sheet

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for Sheet

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Serialize for Sheet

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

§

impl Freeze for Sheet

§

impl RefUnwindSafe for Sheet

§

impl Send for Sheet

§

impl Sync for Sheet

§

impl Unpin for Sheet

§

impl UnsafeUnpin for Sheet

§

impl UnwindSafe for Sheet

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V