Struct Worksheet

Source
pub struct Worksheet {
    pub name: String,
    pub position: u8,
    /* private fields */
}
Expand description

The Worksheet is the primary object in this module since this is where most of the valuable data is. See the methods below for how to use.

Fields§

§name: String§position: u8

Implementations§

Source§

impl Worksheet

Source

pub fn new( relationship_id: String, name: String, position: u8, target: String, sheet_id: u8, ) -> Self

Create a new worksheet. Note that this method will probably not be called directly. Instead, you’ll normally get a worksheet from a Workbook object. E.g.,:

use xl::{Workbook, Worksheet};

let mut wb = Workbook::open("tests/data/Book1.xlsx").unwrap();
let sheets = wb.sheets();
let ws = sheets.get("Time");
assert!(ws.is_some());
Source

pub fn rows<'a>(&self, workbook: &'a mut Workbook) -> RowIter<'a>

Obtain a RowIter for this worksheet (that is in workbook). This is, arguably, the main part of the library. You use this method to iterate through all the values in this sheet. The simplest thing you can do is print the values out (which is what xlcat does), but you could do more if you wanted.

§Example usage
use xl::{Workbook, Worksheet, ExcelValue};

let mut wb = Workbook::open("tests/data/Book1.xlsx").unwrap();
let sheets = wb.sheets();
let ws = sheets.get("Sheet1").unwrap();
let mut rows = ws.rows(&mut wb);
let row1 = rows.next().unwrap();
assert_eq!(row1[0].raw_value, "1");
assert_eq!(row1[1].value, ExcelValue::Number(2f64));

Trait Implementations§

Source§

impl Debug for Worksheet

Source§

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

Formats the value using the given formatter. Read more

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<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, 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.