pub struct Range<'a> { /* private fields */ }Expand description
A rectangular, calamine-style view over a worksheet’s effective cells.
Range is built from a Sheet using Excel’s last-write-wins semantics for
duplicate coordinates. Positions passed to Range::get are relative to the
range start; absolute positions are available from Range::used_cells_abs.
Implementations§
Source§impl<'a> Range<'a>
impl<'a> Range<'a>
Sourcepub fn new(start: (u32, u32), end: (u32, u32)) -> Self
pub fn new(start: (u32, u32), end: (u32, u32)) -> Self
Construct a rectangular sparse range with no populated cells.
The positions use absolute worksheet coordinates. rxls stores worksheet
columns as u16, so columns outside that grid panic instead of silently
changing the requested rectangle.
§Panics
Panics if start is after end, or if either column is outside rxls’
worksheet grid.
Sourcepub fn empty() -> Self
pub fn empty() -> Self
Construct an empty range.
rxls represents missing worksheet positions as None in range APIs, so
an empty range has no rectangular bounds and iterates no cells.
Sourcepub fn from_sparse<I, V>(cells: I) -> Self
pub fn from_sparse<I, V>(cells: I) -> Self
Construct a range from sparse owned cells.
The input positions use absolute worksheet coordinates. The resulting
range bounds are the minimum rectangular area covering all supplied
cells, while missing positions remain None in rxls’ sparse facade.
§Panics
Panics if any column is outside rxls’ worksheet grid.
Sourcepub fn set_value(&mut self, pos: (u32, u32), value: impl Into<Cell>)
pub fn set_value(&mut self, pos: (u32, u32), value: impl Into<Cell>)
Set a cell value at an absolute worksheet position.
If the position extends beyond the current bottom-right bound, the range
grows to include it. Positions above or left of an existing range start
panic, matching calamine’s Range::set_value contract while preserving
rxls’ sparse None representation for other missing cells.
§Panics
Panics if pos is above or left of an existing range start, or if the
column is outside rxls’ worksheet grid.
Sourcepub fn start(&self) -> Option<(u32, u32)>
pub fn start(&self) -> Option<(u32, u32)>
Absolute (row, col) of the top-left cell in the used rectangle.
Sourcepub fn end(&self) -> Option<(u32, u32)>
pub fn end(&self) -> Option<(u32, u32)>
Absolute (row, col) of the bottom-right cell in the used rectangle.
Sourcepub fn dimensions_info(&self) -> Option<Dimensions>
pub fn dimensions_info(&self) -> Option<Dimensions>
Inclusive dimensions of the used rectangle.
Sourcepub fn get_size(&self) -> (usize, usize)
pub fn get_size(&self) -> (usize, usize)
Alias for Range::size, matching calamine naming.
Sourcepub fn range(&self, start: (u32, u32), end: (u32, u32)) -> Self
pub fn range(&self, start: (u32, u32), end: (u32, u32)) -> Self
Build a new rectangular subrange from absolute worksheet coordinates.
This mirrors calamine’s Range::range shape while preserving rxls’
sparse representation: positions without a cell remain None in
Range::rows and Range::cells.
Sourcepub fn get(&self, pos: (usize, usize)) -> Option<&Cell>
pub fn get(&self, pos: (usize, usize)) -> Option<&Cell>
Get a cell by relative (row, col) within the range.
Sourcepub fn get_abs(&self, row: u32, col: u16) -> Option<&Cell>
pub fn get_abs(&self, row: u32, col: u16) -> Option<&Cell>
Get a cell by absolute worksheet (row, col).
Sourcepub fn get_value(&self, pos: (u32, u32)) -> Option<&Cell>
pub fn get_value(&self, pos: (u32, u32)) -> Option<&Cell>
Get a cell by absolute worksheet (row, col), matching calamine’s
Range::get_value naming. Columns outside this crate’s u16 grid return
None.
Sourcepub fn formatted(&self, pos: (usize, usize)) -> Option<&str>
pub fn formatted(&self, pos: (usize, usize)) -> Option<&str>
Get a cell’s formatted display text by relative (row, col) within the
range.
Sourcepub fn formatted_abs(&self, row: u32, col: u16) -> Option<&str>
pub fn formatted_abs(&self, row: u32, col: u16) -> Option<&str>
Get a cell’s formatted display text by absolute worksheet (row, col).
Sourcepub fn headers(&self) -> Option<Vec<String>>
pub fn headers(&self) -> Option<Vec<String>>
First rectangular row as display strings, suitable for serde headers. Missing sparse cells are represented as empty strings.
Sourcepub fn rows(
&self,
) -> impl DoubleEndedIterator<Item = Vec<Option<&Cell>>> + ExactSizeIterator + FusedIterator + '_
pub fn rows( &self, ) -> impl DoubleEndedIterator<Item = Vec<Option<&Cell>>> + ExactSizeIterator + FusedIterator + '_
Iterate rectangular rows from top to bottom.
Each row contains one entry per column in the used rectangle. Missing
sparse cells are represented as None.
Sourcepub fn row_views(&self) -> RangeRows<'_, 'a> ⓘ
pub fn row_views(&self) -> RangeRows<'_, 'a> ⓘ
Iterate borrowed row views from top to bottom without allocating one
Vec per row.
Sourcepub fn used_cells(
&self,
) -> impl DoubleEndedIterator<Item = (u32, u16, &Cell)> + ExactSizeIterator + FusedIterator + '_
pub fn used_cells( &self, ) -> impl DoubleEndedIterator<Item = (u32, u16, &Cell)> + ExactSizeIterator + FusedIterator + '_
Iterate the non-empty effective cells as relative (row, col, cell).
Coordinates are zero-based offsets from Range::start, matching
calamine’s Range::used_cells semantics. Use Range::used_cells_abs
when worksheet-absolute coordinates are needed.
Sourcepub fn used_cells_abs(
&self,
) -> impl DoubleEndedIterator<Item = (u32, u16, &Cell)> + ExactSizeIterator + FusedIterator + '_
pub fn used_cells_abs( &self, ) -> impl DoubleEndedIterator<Item = (u32, u16, &Cell)> + ExactSizeIterator + FusedIterator + '_
Iterate the non-empty effective cells as absolute worksheet
(row, col, cell).
Sourcepub fn cells(
&self,
) -> impl DoubleEndedIterator<Item = (usize, usize, Option<&Cell>)> + ExactSizeIterator + FusedIterator + '_
pub fn cells( &self, ) -> impl DoubleEndedIterator<Item = (usize, usize, Option<&Cell>)> + ExactSizeIterator + FusedIterator + '_
Iterate every rectangular cell position as (relative_row, relative_col, cell). Missing sparse cells are represented as None.
Sourcepub fn deserialize<D>(&'a self) -> Result<RangeDeserializer<'a, D>, DeError>where
D: Deserialize<'a>,
pub fn deserialize<D>(&'a self) -> Result<RangeDeserializer<'a, D>, DeError>where
D: Deserialize<'a>,
Build a typed row deserializer with the default header-row behavior.