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>
impl<'a> Worksheet<'a>
Sourcepub fn describe(&self) -> String
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.
Sourcepub fn describe_cell(&self, row: usize, col: usize) -> String
pub fn describe_cell(&self, row: usize, col: usize) -> String
One cell of this sheet as the caller names it.
Sourcepub fn get_value_by_id(&self, cell_id: &CellId) -> Result<Value, Error>
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.
Sourcepub fn get_value(&self, row: usize, col: usize) -> Result<Value, Error>
pub fn get_value(&self, row: usize, col: usize) -> Result<Value, Error>
A cell’s computed value, unformatted. Empty cells read as Value::Empty.
Sourcepub fn get_formula(&self, row: usize, col: usize) -> Result<String, Error>
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.
Sourcepub fn get_cell_coordinate_by_id(
&self,
cell_id: &CellId,
) -> Result<CellCoordinate, Error>
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.
Sourcepub fn get_cell_info_by_cell_id(
&self,
cell_id: &CellId,
) -> Result<CellInfo, Error>
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.
Sourcepub fn get_conditional_formatting_rules(&self) -> Vec<CfRuleInfo>
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.
Sourcepub fn get_cell_info(&self, row: usize, col: usize) -> Result<CellInfo, Error>
pub fn get_cell_info(&self, row: usize, col: usize) -> Result<CellInfo, Error>
Everything about the cell at a position.
Sourcepub fn get_cell_images(&self) -> Vec<CellImageInfo>
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.
Sourcepub fn get_charts(&self) -> Vec<ChartInfo>
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.
Sourcepub fn get_cell_infos(
&self,
start_row: usize,
start_col: usize,
end_row: usize,
end_col: usize,
) -> Result<Vec<CellInfo>, Error>
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.
Sourcepub 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>
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.
Sourcepub fn get_reproducible_cell(
&self,
row: usize,
col: usize,
) -> Result<ReproducibleCell, Error>
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.
pub fn get_reproducible_cells( &self, coordinates: Vec<SheetCoordinate>, ) -> Result<Vec<ReproducibleCell>, Error>
Sourcepub fn get_comment(&self, row: usize, col: usize) -> Option<Comment>
pub fn get_comment(&self, row: usize, col: usize) -> Option<Comment>
The comment thread on a cell, if any.
Sourcepub fn get_diy_cell_id_with_block_id(
&self,
block_id: &usize,
row: usize,
col: usize,
) -> Option<u32>
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.
Sourcepub fn get_display_window(
&self,
start_row: usize,
start_col: usize,
end_row: usize,
end_col: usize,
) -> Result<DisplayWindow, Error>
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.
Sourcepub fn get_cell_position(
&self,
row: usize,
col: usize,
) -> Result<CellPosition, Error>
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.
Sourcepub fn get_diy_cell_id(&self, row: usize, col: usize) -> Result<u32, Error>
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.
Sourcepub fn get_display_window_for_block(
&self,
block_id: usize,
) -> Result<DisplayWindow, Error>
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).
Sourcepub fn get_display_window_response(
&self,
start_x: f64,
start_y: f64,
width: f64,
height: f64,
) -> Result<DisplayWindowWithStartPoint, Error>
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.
Sourcepub fn get_nearest_row_with_given_y(
&self,
y: f64,
before: bool,
positioner: &mut CellPositioner<1000>,
) -> Result<(usize, f64), Error>
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.
Sourcepub fn get_nearest_col_with_given_x(
&self,
x: f64,
before: bool,
positioner: &mut CellPositioner<1000>,
) -> Result<(usize, f64), Error>
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).
Sourcepub fn get_next_upward_visible_cell(
&self,
row: usize,
col: usize,
) -> Result<CellCoordinate, Error>
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.
Sourcepub fn get_next_downward_visible_cell(
&self,
row: usize,
col: usize,
) -> Result<CellCoordinate, Error>
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.
Sourcepub fn get_next_leftward_visible_cell(
&self,
row: usize,
col: usize,
) -> Result<CellCoordinate, Error>
pub fn get_next_leftward_visible_cell( &self, row: usize, col: usize, ) -> Result<CellCoordinate, Error>
Arrow-key move leftward; errors at column 0.
Sourcepub fn get_next_rightward_visible_cell(
&self,
row: usize,
col: usize,
) -> Result<CellCoordinate, Error>
pub fn get_next_rightward_visible_cell( &self, row: usize, col: usize, ) -> Result<CellCoordinate, Error>
Arrow-key move rightward.
Sourcepub fn get_upward_data_boundary(
&self,
row: usize,
col: usize,
) -> Result<CellCoordinate, Error>
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.
Sourcepub fn get_downward_data_boundary(
&self,
row: usize,
col: usize,
) -> Result<CellCoordinate, Error>
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.
Sourcepub fn get_leftward_data_boundary(
&self,
row: usize,
col: usize,
) -> Result<CellCoordinate, Error>
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.
Sourcepub fn get_rightward_data_boundary(
&self,
row: usize,
col: usize,
) -> Result<CellCoordinate, Error>
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.
Sourcepub fn get_cell_info_in_window(
&self,
start_row: usize,
start_col: usize,
end_row: usize,
end_col: usize,
) -> Result<Vec<CellInfo>, Error>
pub fn get_cell_info_in_window( &self, start_row: usize, start_col: usize, end_row: usize, end_col: usize, ) -> Result<Vec<CellInfo>, Error>
Same as Worksheet::get_cell_infos.
Sourcepub fn get_style(&self, row: usize, col: usize) -> Result<Style, Error>
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.
Sourcepub fn get_all_merged_cells(&self) -> Vec<MergeCell>
pub fn get_all_merged_cells(&self) -> Vec<MergeCell>
Every merge on the sheet at its current position (inclusive corners).
pub fn get_merged_cells( &self, t_start_row: usize, t_start_col: usize, t_end_row: usize, t_end_col: usize, ) -> Vec<MergeCell>
pub fn get_comments(&self) -> Vec<Comment>
Sourcepub fn get_all_fully_covered_blocks(
&self,
start_row: usize,
start_col: usize,
end_row: usize,
end_col: usize,
) -> Vec<BlockInfo>
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.
Sourcepub fn get_linkable_blocks(&self, col_cnt: usize) -> Vec<BlockInfo>
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.
Sourcepub fn get_links(&self) -> Vec<LinkInfo>
pub fn get_links(&self) -> Vec<LinkInfo>
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).
pub fn get_all_blocks(&self) -> Vec<BlockInfo>
Sourcepub fn get_sheet_dimension(&self) -> Result<SheetDimension, Error>
pub fn get_sheet_dimension(&self) -> Result<SheetDimension, Error>
Get the dimension of the sheet.
Sourcepub fn get_dependents(
&self,
start_row: usize,
start_col: usize,
end_row: usize,
end_col: usize,
) -> Result<Vec<DependentCell>, Error>
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.
Sourcepub fn get_precedents(
&self,
row: usize,
col: usize,
) -> Result<Vec<CellRefRange>, Error>
pub fn get_precedents( &self, row: usize, col: usize, ) -> Result<Vec<CellRefRange>, Error>
The ranges/cells a cell’s formula references (Excel “trace precedents”).
Sourcepub fn get_row_info(&self, row: usize) -> Option<RowInfo>
pub fn get_row_info(&self, row: usize) -> Option<RowInfo>
None when the row has no stored info (default height, visible).
Sourcepub fn get_col_info(&self, col: usize) -> Option<ColInfo>
pub fn get_col_info(&self, col: usize) -> Option<ColInfo>
None when the column has no stored info (default width, visible).
Sourcepub fn get_row_height(&self, row: usize) -> Result<f64, Error>
pub fn get_row_height(&self, row: usize) -> Result<f64, Error>
Row height in points; the sheet default unless custom.
Sourcepub fn get_col_width(&self, col: usize) -> Result<f64, Error>
pub fn get_col_width(&self, col: usize) -> Result<f64, Error>
Column width in character-width units; the sheet default unless custom.
Sourcepub fn get_default_row_height(&self) -> f64
pub fn get_default_row_height(&self) -> f64
The sheet’s default row height in points (from the file’s
sheetFormatPr, else 15).
Sourcepub fn get_default_col_width(&self) -> f64
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).
pub fn get_display_block_info( &self, block_id: usize, ) -> Result<BlockDisplayInfo, Error>
pub fn get_block_info(&self, block_id: usize) -> Result<BlockInfo, Error>
Sourcepub fn get_block_place(&self, block_id: usize) -> Result<&BlockPlace, Error>
pub fn get_block_place(&self, block_id: usize) -> Result<&BlockPlace, Error>
The block’s internal placement record.
Sourcepub fn get_block_size(&self, block_id: usize) -> Result<(usize, usize), Error>
pub fn get_block_size(&self, block_id: usize) -> Result<(usize, usize), Error>
(row_count, col_count).
Sourcepub fn get_block_master_cell(
&self,
block_id: usize,
) -> Result<(usize, usize), Error>
pub fn get_block_master_cell( &self, block_id: usize, ) -> Result<(usize, usize), Error>
Sheet (row, col) of the block’s top-left cell.
Sourcepub fn get_block_row_id(
&self,
block_id: usize,
row_idx: usize,
) -> Result<u32, Error>
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.
Sourcepub fn get_block_col_id(
&self,
block_id: usize,
col_idx: usize,
) -> Result<u32, Error>
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.
Sourcepub fn get_cell_id(&self, row: usize, col: usize) -> Result<CellId, Error>
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).
Sourcepub fn lookup_appendix_upward(
&self,
block_id: usize,
row_idx: usize,
col_idx: usize,
craft_id: &str,
tag: u8,
) -> Option<AppendixWithCell>
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> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
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 moreimpl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.