Skip to content

Commit

Permalink
add example in README
Browse files Browse the repository at this point in the history
  • Loading branch information
PrettyWood committed Oct 5, 2024
1 parent 65d4c2d commit d481deb
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,24 @@ if let Some(Ok(r)) = excel.worksheet_range("Sheet1") {
}
```

### Reader: With options

```rs
use calamine::{Reader, Xlsx, XlsxOptions, open_workbook};

let mut excel: Xlsx<_> = open_workbook("file.xlsx").unwrap();

let sheet1 = excel
.with_options(XlsxOptions::default().with_header_row(3))
.worksheet_range("Sheet1")
.unwrap();
```

Note that for `xlsx` and `xlsb` support lazy loading so the options
are applied directly when reading a sheet.
For `xls` and `ods`, all sheets are loaded when loading the workbook,
which means options are applied after and won't have any benefits in terms of performance.

### Reader: More complex

Let's assume
Expand Down Expand Up @@ -190,7 +208,7 @@ The programs are all structured to follow the same constructs:
use calamine::{open_workbook, Reader, Xlsx};

fn main() {
// Open workbook
// Open workbook
let mut excel: Xlsx<_> =
open_workbook("NYC_311_SR_2010-2020-sample-1M.xlsx").expect("failed to find file");

Expand Down

0 comments on commit d481deb

Please sign in to comment.