Struct calamine::Range [] [src]

pub struct Range<T: CellType> { /* fields omitted */ }

A struct which represents a squared selection of cells

Methods

impl<T: CellType> Range<T>
[src]

[src]

Creates a new Range

When possible, prefer the more efficient Range::from_sparse

[src]

Get top left cell position (row, column)

[src]

Get bottom right cell position (row, column)

[src]

Get column width

[src]

Get column width

[src]

Get size in (height, width) format

[src]

Is range empty

[src]

Creates a Range from a coo sparse vector of Cells.

Coordinate list (COO) is the natural way cells are stored Inner size is defined only by non empty.

cells: Vec of non empty Cells, sorted by row

Panics

panics when a Cell row is lower than the first Cell row or bigger than the last Cell row.

[src]

Set inner value from absolute position

Will try to resize inner structure if the value is out of bounds. For relative positions, use Index trait

Try to avoid this method as much as possible and prefer initializing the Range with from_sparce constructor.

Panics

If absolute_position > Cell start

Examples

use calamine::{Range, DataType};

let mut range = Range::new((0, 0), (5, 2));
assert_eq!(range.get_value((2, 1)), &DataType::Empty);
range.set_value((2, 1), DataType::Float(1.0));
assert_eq!(range.get_value((2, 1)), &DataType::Float(1.0));

[src]

Get cell value from absolute position

The coordinate format is (row, column). For relative positions, use Index trait

Panics if indexes are out of range bounds

Important traits for Rows<'a, T>
[src]

Get an iterator over inner rows

Examples

use calamine::{Range, DataType};

let range: Range<DataType> = Range::new((0, 0), (5, 2));
// with rows item row: &[DataType]
assert_eq!(range.rows().map(|r| r.len()).sum::<usize>(), 18);

Important traits for UsedCells<'a, T>
[src]

Get an iterator over used cells only

[src]

Build a RangeDeserializer from this configuration.

Example

fn example() -> Result<(), Error> {
    let path = format!("{}/tests/tempurature.xlsx", env!("CARGO_MANIFEST_DIR"));
    let mut workbook: Xlsx<_> = open_workbook(path)?;
    let mut sheet = workbook.worksheet_range("Sheet1")
        .ok_or(Error::Msg("Cannot find 'Sheet1'"))??;
    let mut iter = sheet.deserialize()?;

    if let Some(result) = iter.next() {
        let (label, value): (String, f64) = result?;
        assert_eq!(label, "celcius");
        assert_eq!(value, 22.2222);

        Ok(())
    } else {
        return Err(From::from("expected at least one record but got none"));
    }
}

Trait Implementations

impl<T: Debug + CellType> Debug for Range<T>
[src]

[src]

Formats the value using the given formatter. Read more

impl<T: Default + CellType> Default for Range<T>
[src]

[src]

Returns the "default value" for a type. Read more

impl<T: Clone + CellType> Clone for Range<T>
[src]

[src]

Returns a copy of the value. Read more

1.0.0
[src]

Performs copy-assignment from source. Read more

impl<T: CellType> Index<usize> for Range<T>
[src]

The returned type after indexing.

[src]

Performs the indexing (container[index]) operation.

impl<T: CellType> Index<(usize, usize)> for Range<T>
[src]

The returned type after indexing.

[src]

Performs the indexing (container[index]) operation.

impl<T: CellType> IndexMut<usize> for Range<T>
[src]

[src]

Performs the mutable indexing (container[index]) operation.

impl<T: CellType> IndexMut<(usize, usize)> for Range<T>
[src]

[src]

Performs the mutable indexing (container[index]) operation.

Auto Trait Implementations

impl<T> Send for Range<T> where
    T: Send

impl<T> Sync for Range<T> where
    T: Sync