diff --git a/base/src/expressions/parser/mod.rs b/base/src/expressions/parser/mod.rs index 8281cf5..af9e33a 100644 --- a/base/src/expressions/parser/mod.rs +++ b/base/src/expressions/parser/mod.rs @@ -717,7 +717,7 @@ impl Parser { return Node::ParseErrorKind { formula: self.lexer.get_formula(), position: 0, - message: "sheet not found".to_string(), + message: format!("sheet not found: {}", context.sheet), }; } }; @@ -850,7 +850,7 @@ impl Parser { return Node::ParseErrorKind { formula: self.lexer.get_formula(), position: 0, - message: "sheet not found".to_string(), + message: format!("sheet not found: {}", context.sheet), }; } }; @@ -878,7 +878,7 @@ impl Parser { return Node::ParseErrorKind { formula: self.lexer.get_formula(), position: 0, - message: "sheet not found".to_string(), + message: format!("table sheet not found: {}", table.sheet_name), }; } }; diff --git a/xlsx/tests/templates/mortgage_calculator.xlsx b/xlsx/tests/templates/mortgage_calculator.xlsx new file mode 100644 index 0000000..60aaa38 Binary files /dev/null and b/xlsx/tests/templates/mortgage_calculator.xlsx differ diff --git a/xlsx/tests/templates/travel_expenses_tracker.xlsx b/xlsx/tests/templates/travel_expenses_tracker.xlsx new file mode 100644 index 0000000..809e607 Binary files /dev/null and b/xlsx/tests/templates/travel_expenses_tracker.xlsx differ diff --git a/xlsx/tests/test.rs b/xlsx/tests/test.rs index da4bdaa..991bdbd 100644 --- a/xlsx/tests/test.rs +++ b/xlsx/tests/test.rs @@ -472,6 +472,45 @@ fn test_exporting_merged_cells() { fs::remove_file(temp_file_name).unwrap(); } +#[test] +fn test_templates_xlsx() { + let mut entries = fs::read_dir("tests/templates/") + .unwrap() + .map(|res| res.map(|e| e.path())) + .collect::, io::Error>>() + .unwrap(); + entries.sort(); + let temp_folder = env::temp_dir(); + let path = format!("{}", Uuid::new_v4()); + let dir = temp_folder.join(path); + fs::create_dir(&dir).unwrap(); + let mut is_error = false; + for file_path in entries { + let file_name_str = file_path.file_name().unwrap().to_str().unwrap(); + let file_path_str = file_path.to_str().unwrap(); + println!("Testing file: {file_path_str}"); + if file_name_str.ends_with(".xlsx") && !file_name_str.starts_with('~') { + if let Err(message) = test_file(file_path_str) { + println!("Error with file: '{file_path_str}'"); + println!("{message}"); + is_error = true; + } + let t = test_load_and_saving(file_path_str, &dir); + if t.is_err() { + println!("Error while load and saving file: {file_path_str}"); + is_error = true; + } + } else { + println!("skipping"); + } + } + fs::remove_dir_all(&dir).unwrap(); + assert!( + !is_error, + "Models were evaluated inconsistently with XLSX data." + ); +} + #[test] fn test_documentation_xlsx() { let mut entries = fs::read_dir("tests/docs/")