UPDATE: Adds load_from_xlsx_bytes (#86)
This is usefull if we are transfering bytes, for instance over the internet
This commit is contained in:
committed by
GitHub
parent
b9bf485379
commit
40aa8bebaf
@@ -1,9 +1,10 @@
|
||||
use std::io::Read;
|
||||
use std::{env, fs, io};
|
||||
use uuid::Uuid;
|
||||
|
||||
use ironcalc::compare::{test_file, test_load_and_saving};
|
||||
use ironcalc::export::save_to_xlsx;
|
||||
use ironcalc::import::{load_from_icalc, load_from_xlsx};
|
||||
use ironcalc::import::{load_from_icalc, load_from_xlsx, load_from_xlsx_bytes};
|
||||
use ironcalc_base::types::{HorizontalAlignment, VerticalAlignment};
|
||||
use ironcalc_base::Model;
|
||||
|
||||
@@ -48,6 +49,16 @@ fn test_example() {
|
||||
assert_eq!(workbook, model2.workbook, "{:?}", s);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_load_from_xlsx_bytes() {
|
||||
let file_path = std::path::Path::new("tests/example.xlsx");
|
||||
let mut file = fs::File::open(file_path).unwrap();
|
||||
let mut bytes = Vec::new();
|
||||
file.read_to_end(&mut bytes).unwrap();
|
||||
let workbook = load_from_xlsx_bytes(&bytes, "home", "en", "UTC").unwrap();
|
||||
assert_eq!(workbook.views[&0].sheet, 7);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn no_grid() {
|
||||
let model = load_from_xlsx("tests/NoGrid.xlsx", "en", "UTC").unwrap();
|
||||
|
||||
Reference in New Issue
Block a user