Skip to main content

Worksheet

Struct Worksheet 

Source
pub struct Worksheet<'a> { /* private fields */ }
Expand description

A read-only view of one sheet, borrowed from a crate::Workbook.

Rows and columns are 0-based. Position queries (get_cell_position, display windows) return CellPosition offsets — points on the y axis, character-width units on the x axis — and share a per-sheet offset cache (positioner) with the workbook.

Implementations§

Source§

impl<'a> Worksheet<'a>

Source

pub fn describe(&self) -> String

This sheet as the caller names it, for error context. The engine addresses sheets by id; nobody outside it does.

Source

pub fn describe_cell(&self, row: usize, col: usize) -> String

One cell of this sheet as the caller names it.

Source

pub fn get_value_by_id(&self, cell_id: &CellId) -> Result<Value, Error>

A cell’s computed value by stable id; a cell with nothing stored reads as Value::Empty, never an error.

Source

pub fn get_value(&self, row: usize, col: usize) -> Result<Value, Error>

A cell’s computed value, unformatted. Empty cells read as Value::Empty.

Source

pub fn get_formula(&self, row: usize, col: usize) -> Result<String, Error>

The cell’s formula rendered from its AST, WITHOUT the leading = (normalised, so not necessarily as typed); "" when there is none.

Source

pub fn get_cell_coordinate_by_id( &self, cell_id: &CellId, ) -> Result<CellCoordinate, Error>

Current position of a cell id. Mind the axes: the result’s x is the column and y the row. Errors for ephemeral or deleted cells.

Source

pub fn get_cell_info_by_cell_id( &self, cell_id: &CellId, ) -> Result<CellInfo, Error>

Everything about a cell (value, formula, style, block, shadows) by id.

Source

pub fn get_conditional_formatting_rules(&self) -> Vec<CfRuleInfo>

The conditional formatting in effect for cell_id: decode the match bitmask from the cell’s ConditionalFormat shadow, merge the matching rules’ dxfs onto the cell’s own style in priority order, and pick up the scale shadow for a colour scale / data bar.

None when the sheet has no rules covering the cell, or when no rule currently matches and no scale applies — the caller then just renders CellInfo::style. Every conditional-formatting rule on this sheet, in priority order — the order Excel applies them, and the order a rule-manager dialog lists them in.

spec round-trips: hand it back in an UpdateConditionalFormattingRule to edit the rule in place.

Source

pub fn get_cell_info(&self, row: usize, col: usize) -> Result<CellInfo, Error>

Everything about the cell at a position.

Source

pub fn get_cell_images(&self) -> Vec<CellImageInfo>

All images placed in this sheet’s cells, each resolved to its current (row, col) position with the bytes base64-encoded for transport. Images whose anchor cell no longer exists are skipped.

Source

pub fn get_charts(&self) -> Vec<ChartInfo>

All charts anchored on this sheet, each resolved to its current from/to cell positions. Charts whose anchor cells no longer exist are skipped. data (type, series, cached values) comes from the chart’s parsed OOXML; the frontend re-reads live values from the source ranges.

Source

pub fn get_cell_infos( &self, start_row: usize, start_col: usize, end_row: usize, end_col: usize, ) -> Result<Vec<CellInfo>, Error>

CellInfo for every cell of the inclusive rectangle, row-major.

Source

pub fn get_cell_infos_except_window( &self, start_row: usize, start_col: usize, end_row: usize, end_col: usize, window_start_row: usize, window_start_col: usize, window_end_row: usize, window_end_col: usize, ) -> Result<Vec<CellInfo>, Error>

Worksheet::get_cell_infos minus the cells inside the inclusive window_* rectangle, for incremental redraws.

Source

pub fn get_reproducible_cell( &self, row: usize, col: usize, ) -> Result<ReproducibleCell, Error>

Snapshot a cell’s value, raw style and appendices for ReproduceCells (copy/paste). Formulas are not captured.

Source

pub fn get_reproducible_cells( &self, coordinates: Vec<SheetCoordinate>, ) -> Result<Vec<ReproducibleCell>, Error>

Source

pub fn get_comment(&self, row: usize, col: usize) -> Option<Comment>

The comment thread on a cell, if any.

Source

pub fn get_diy_cell_id_with_block_id( &self, block_id: &usize, row: usize, col: usize, ) -> Option<u32>

The DIY id of a block cell, addressed by 0-based offsets within the block.

Source

pub fn get_display_window( &self, start_row: usize, start_col: usize, end_row: usize, end_col: usize, ) -> Result<DisplayWindow, Error>

Everything needed to paint the inclusive rectangle, skipping hidden rows. Hidden columns are detected on start_row only, so a hidden start_row leaves cols empty and hidden columns’ cells included.

Source

pub fn get_cell_position( &self, row: usize, col: usize, ) -> Result<CellPosition, Error>

Offset of the cell’s top-left corner from the sheet origin (points down, character widths across; see CellPosition). Passing row + 1 / col + 1 gives the far corner.

Source

pub fn get_diy_cell_id(&self, row: usize, col: usize) -> Result<u32, Error>

The DIY id of the cell at a sheet position; errors when it is not a DIY block cell.

Source

pub fn get_display_window_for_block( &self, block_id: usize, ) -> Result<DisplayWindow, Error>

The cells, comments and merges of one block, every row and column of it (row-major).

Source

pub fn get_display_window_response( &self, start_x: f64, start_y: f64, width: f64, height: f64, ) -> Result<DisplayWindowWithStartPoint, Error>

The display window covering a viewport given in CellPosition units, widened by one row and column before it. start_x/start_y in the result are the offsets of the first row/column returned, for aligning the drawing.

Source

pub fn get_nearest_row_with_given_y( &self, y: f64, before: bool, positioner: &mut CellPositioner<1000>, ) -> Result<(usize, f64), Error>

The row boundary at or after offset y (points) as (row, row_start); with before, step back one row so the row containing y is returned.

Source

pub fn get_nearest_col_with_given_x( &self, x: f64, before: bool, positioner: &mut CellPositioner<1000>, ) -> Result<(usize, f64), Error>

Column counterpart of Worksheet::get_nearest_row_with_given_y (x in character-width units).

Source

pub fn get_next_upward_visible_cell( &self, row: usize, col: usize, ) -> Result<CellCoordinate, Error>

Arrow-key move: the nearest non-hidden cell above (x = column, y = row). Errors at row 0; stops at row 0 even if it is hidden.

Source

pub fn get_next_downward_visible_cell( &self, row: usize, col: usize, ) -> Result<CellCoordinate, Error>

Arrow-key move downward; see Worksheet::get_next_upward_visible_cell.

Source

pub fn get_next_leftward_visible_cell( &self, row: usize, col: usize, ) -> Result<CellCoordinate, Error>

Arrow-key move leftward; errors at column 0.

Source

pub fn get_next_rightward_visible_cell( &self, row: usize, col: usize, ) -> Result<CellCoordinate, Error>

Arrow-key move rightward.

Source

pub fn get_upward_data_boundary( &self, row: usize, col: usize, ) -> Result<CellCoordinate, Error>

Ctrl+Up: jump upward to the next data or block boundary in this column.

Source

pub fn get_downward_data_boundary( &self, row: usize, col: usize, ) -> Result<CellCoordinate, Error>

Ctrl+Down: jump downward to the next data or block boundary in this column.

Source

pub fn get_leftward_data_boundary( &self, row: usize, col: usize, ) -> Result<CellCoordinate, Error>

Ctrl+Left: jump left to the next data or block boundary in this row.

Source

pub fn get_rightward_data_boundary( &self, row: usize, col: usize, ) -> Result<CellCoordinate, Error>

Ctrl+Right: jump right to the next data or block boundary in this row.

Source

pub fn get_cell_info_in_window( &self, start_row: usize, start_col: usize, end_row: usize, end_col: usize, ) -> Result<Vec<CellInfo>, Error>

Source

pub fn get_style(&self, row: usize, col: usize) -> Result<Style, Error>

The cell’s effective style — its own, else its row’s, else its column’s (block lines for a block cell) — resolved against the theme.

Source

pub fn get_all_merged_cells(&self) -> Vec<MergeCell>

Every merge on the sheet at its current position (inclusive corners).

Source

pub fn get_merged_cells( &self, t_start_row: usize, t_start_col: usize, t_end_row: usize, t_end_col: usize, ) -> Vec<MergeCell>

Source

pub fn get_comments(&self) -> Vec<Comment>

Source

pub fn get_all_fully_covered_blocks( &self, start_row: usize, start_col: usize, end_row: usize, end_col: usize, ) -> Vec<BlockInfo>

Blocks lying entirely inside the inclusive rectangle.

Source

pub fn get_linkable_blocks(&self, col_cnt: usize) -> Vec<BlockInfo>

Blocks on this sheet a col_cnt-wide range can be linked to: same column count, and not already the target of a link.

Every range on this sheet that is linked to a block, resolved to sheet coordinates. Used by the app to draw an outer border around each linked source range. Unbounded row/col link sources are skipped (no finite box).

Source

pub fn get_all_blocks(&self) -> Vec<BlockInfo>

Source

pub fn get_sheet_dimension(&self) -> Result<SheetDimension, Error>

Get the dimension of the sheet.

Source

pub fn get_dependents( &self, start_row: usize, start_col: usize, end_row: usize, end_col: usize, ) -> Result<Vec<DependentCell>, Error>

Cells whose formula references the given range (Excel “trace dependents”). One entry per (dependent cell, the reference it used) intersecting the query rectangle. Dependents may live on other sheets (each carries its own sheet_idx). v1 resolves normal (non-block) range references; block-relative / cube / name references are skipped.

Source

pub fn get_precedents( &self, row: usize, col: usize, ) -> Result<Vec<CellRefRange>, Error>

The ranges/cells a cell’s formula references (Excel “trace precedents”).

Source

pub fn get_row_info(&self, row: usize) -> Option<RowInfo>

None when the row has no stored info (default height, visible).

Source

pub fn get_col_info(&self, col: usize) -> Option<ColInfo>

None when the column has no stored info (default width, visible).

Source

pub fn is_row_hidden(&self, row: usize) -> bool

Source

pub fn is_col_hidden(&self, col: usize) -> bool

Source

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

Row height in points; the sheet default unless custom.

Source

pub fn get_col_width(&self, col: usize) -> Result<f64, Error>

Column width in character-width units; the sheet default unless custom.

Source

pub fn get_default_row_height(&self) -> f64

The sheet’s default row height in points (from the file’s sheetFormatPr, else 15).

Source

pub fn get_default_col_width(&self) -> f64

The sheet’s default column width in character-width units (from the file’s sheetFormatPr, else 8.43).

Source

pub fn get_display_block_info( &self, block_id: usize, ) -> Result<BlockDisplayInfo, Error>

Source

pub fn get_block_info(&self, block_id: usize) -> Result<BlockInfo, Error>

Source

pub fn get_block_place(&self, block_id: usize) -> Result<&BlockPlace, Error>

The block’s internal placement record.

Source

pub fn get_block_size(&self, block_id: usize) -> Result<(usize, usize), Error>

(row_count, col_count).

Source

pub fn get_block_master_cell( &self, block_id: usize, ) -> Result<(usize, usize), Error>

Sheet (row, col) of the block’s top-left cell.

Source

pub fn get_block_row_id( &self, block_id: usize, row_idx: usize, ) -> Result<u32, Error>

The block’s own row id at 0-based offset row_idx within the block.

Source

pub fn get_block_col_id( &self, block_id: usize, col_idx: usize, ) -> Result<u32, Error>

The block’s own column id at 0-based offset col_idx within the block.

Source

pub fn get_cell_id(&self, row: usize, col: usize) -> Result<CellId, Error>

The stable id of the cell at a position (a block cell inside a block).

Source

pub fn lookup_appendix_upward( &self, block_id: usize, row_idx: usize, col_idx: usize, craft_id: &str, tag: u8, ) -> Option<AppendixWithCell>

Search the block column col_idx from row_idx upward (inclusive, 0-based within the block) for the nearest appendix with this craft_id and tag.

Auto Trait Implementations§

§

impl<'a> !Freeze for Worksheet<'a>

§

impl<'a> !RefUnwindSafe for Worksheet<'a>

§

impl<'a> !Send for Worksheet<'a>

§

impl<'a> !Sync for Worksheet<'a>

§

impl<'a> !UnwindSafe for Worksheet<'a>

§

impl<'a> Unpin for Worksheet<'a>

§

impl<'a> UnsafeUnpin for Worksheet<'a>

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> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

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

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<SS, SP> SupersetOf<SS> for SP
where SS: SubsetOf<SP>,

Source§

fn to_subset(&self) -> Option<SS>

The inverse inclusion map: attempts to construct self from the equivalent element of its superset. Read more
Source§

fn is_in_subset(&self) -> bool

Checks if self is actually part of its subset T (and can be converted to it).
Source§

fn to_subset_unchecked(&self) -> SS

Use with care! Same as self.to_subset but without any property checks. Always succeeds.
Source§

fn from_subset(element: &SS) -> SP

The inclusion map: converts self to the equivalent element of its superset.
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

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more