UPDATE: have xlsx_2_icalc specify its output name
This is nice for deployments
This commit is contained in:
committed by
Nicolás Hatcher Andrés
parent
3191e12b93
commit
0f8f345aae
@@ -7,7 +7,7 @@
|
||||
//! This is primary for QA internal testing and will be superseded by an official
|
||||
//! IronCalc CLI.
|
||||
//!
|
||||
//! Usage: test file.xlsx
|
||||
//! Usage: test file.xlsx [output.icalc]
|
||||
|
||||
use std::path;
|
||||
|
||||
@@ -15,15 +15,20 @@ use ironcalc::{export::save_to_icalc, import::load_from_xlsx};
|
||||
|
||||
fn main() {
|
||||
let args: Vec<_> = std::env::args().collect();
|
||||
if args.len() != 2 {
|
||||
panic!("Usage: {} <file.xlsx>", args[0]);
|
||||
if args.len() != 2 && args.len() != 3 {
|
||||
panic!("Usage: {} <file.xlsx> [output.icalc]", args[0]);
|
||||
}
|
||||
// first test the file
|
||||
let file_name = &args[1];
|
||||
|
||||
let output_file_name = if args.len() == 3 {
|
||||
&args[2]
|
||||
} else {
|
||||
let file_path = path::Path::new(file_name);
|
||||
let base_name = file_path.file_stem().unwrap().to_str().unwrap();
|
||||
let output_file_name = &format!("{base_name}.ic");
|
||||
&format!("{base_name}.ic")
|
||||
};
|
||||
|
||||
let model = load_from_xlsx(file_name, "en", "UTC").unwrap();
|
||||
save_to_icalc(&model, output_file_name).unwrap();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user