use std::fs::File;
use xlsxzero::ConverterBuilder;
fn main() -> Result<(), Box<dyn std::error::Error>> {
let input_path = std::env::args()
.nth(1)
.unwrap_or_else(|| "examples/fixtures/sample.xlsx".to_string());
let output_path = std::env::args()
.nth(2)
.unwrap_or_else(|| "examples/fixtures/output.md".to_string());
println!("Converting {} to {}...", input_path, output_path);
let converter = ConverterBuilder::new().build()?;
let input = File::open(&input_path).map_err(|e| {
eprintln!("Error: Could not open input file '{}'", input_path);
eprintln!(" {}", e);
eprintln!("\nHint: Create a sample Excel file or provide a path to an existing file.");
e
})?;
let output = File::create(&output_path).map_err(|e| {
eprintln!("Error: Could not create output file '{}'", output_path);
eprintln!(" {}", e);
e
})?;
converter.convert(input, output)?;
println!("Conversion completed successfully!");
println!("Output written to: {}", output_path);
Ok(())
}