Skip to main content

ExcelTable

Struct ExcelTable 

Source
pub struct ExcelTable {
    pub id: u64,
    pub name: String,
    pub sheet_id: u64,
    pub start_row: usize,
    pub start_col: usize,
    pub end_row: usize,
    pub end_col: usize,
    pub has_header_row: bool,
    pub has_totals_row: bool,
    pub columns: Vec<String>,
    pub style_name: Option<String>,
    pub has_insert_row: bool,
}
Expand description

A named, rectangular range within a single worksheet, mirroring an Excel Table (a.k.a. ListObject): a header row, a body of data rows, and an optional totals row, all with stable per-column names that formulas can reference via structured references (e.g. Sales[Amount]).

This is a distinct concept from a Sheet: elsewhere in this codebase a Sheet is informally called a “table” (see Sheet::new’s default name "table_1"), but an ExcelTable is a sub-range that lives on a sheet, exactly like a real Excel Table can occupy only part of a worksheet.

Fields§

§id: u64

Workbook-unique identifier, stable across renames.

§name: String

The table’s name, as a structured reference spells it. Unique workbook-wide and matched case-insensitively.

§sheet_id: u64

The sheet this table occupies part of.

§start_row: usize

Topmost row of the range, 0-based – the header row when there is one.

§start_col: usize

Leftmost column of the range, 0-based.

§end_row: usize

Bottommost row of the range, 0-based and inclusive – the totals row when there is one.

§end_col: usize

Rightmost column of the range, 0-based and inclusive.

§has_header_row: bool

Whether the first row is a header rather than data.

§has_totals_row: bool

Whether the last row is a totals row rather than data.

§columns: Vec<String>

Column names, in sheet-column order, one per column in start_col..=end_col. Kept in sync with the header row’s cell text (when has_header_row is true) by the CRUD methods in this file.

§style_name: Option<String>

Visual style theme name (e.g. “TableStyleMedium9”, “TableStyleLight1”, or custom theme)

§has_insert_row: bool

Whether the last row of the range is Excel’s insert row placeholder rather than data – i.e. the table has zero data rows.

This cannot be inferred from the extent, which is the surprise: deleting a one-data-row table’s only row leaves ref at A1:C2 and sets insertRow="1" in xl/tables/tableN.xml, so a zero-row table and a table with one blank data row have identical bounds. Excel tells them apart by this flag and so must we – ListObject’s .DataBodyRange is Nothing and .ListRows.Count is 0 for the former and a real range and 1 for the latter. Measured with fuzz/vba_table_probe.py --empty, which is issue #11’s shape.

Implementations§

Source§

impl ExcelTable

Source

pub fn set_style_name(&mut self, style_name: Option<String>)

Sets the table’s visual style, or clears it with None.

Source

pub fn row_count(&self) -> usize

Total rows in the range, header and totals rows included.

Source

pub fn col_count(&self) -> usize

Columns in the range.

Source

pub fn data_start_row(&self) -> usize

First row of the table’s actual data body (excludes the header row).

Source

pub fn data_end_row(&self) -> usize

Last row of the table’s actual data body, excluding the totals row and Excel’s insert-row placeholder.

May be less than data_start_row() for a table with no data rows, so callers building a range from the pair must handle the empty case rather than assuming start..=end is non-empty. See ExcelTable::data_row_count.

Source

pub fn data_row_count(&self) -> usize

How many data rows the table actually has, which is 0 for a table sitting on its insert-row placeholder.

Use this rather than comparing data_start_row() with data_end_row(): an empty table’s end is below its start, so the subtraction underflows.

Source

pub fn header_row(&self) -> Option<usize>

The header row’s sheet-row index, or None if the table has no header.

Source

pub fn totals_row(&self) -> Option<usize>

The totals row’s sheet-row index, or None if the table has no totals row.

Source

pub fn local_column_index(&self, name: &str) -> Option<usize>

Index (0-based, relative to the table’s own columns) of the column with the given name, matched case-insensitively as Excel does for structured references.

Source

pub fn overlaps( &self, start_row: usize, start_col: usize, end_row: usize, end_col: usize, ) -> bool

Whether this table’s range overlaps the given rectangular range.

Trait Implementations§

Source§

impl Clone for ExcelTable

Source§

fn clone(&self) -> ExcelTable

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 ExcelTable

Source§

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

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

impl<'de> Deserialize<'de> for ExcelTable

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 PartialEq for ExcelTable

Source§

fn eq(&self, other: &ExcelTable) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl Serialize for ExcelTable

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
Source§

impl StructuralPartialEq for ExcelTable

Auto Trait Implementations§

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 = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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