// Test case that compares a file generated by polars_excel_writer with a file // created by Excel. // // SPDX-License-Identifier: MIT OR Apache-2.0 // // Copyright 2023-2024, John McNamara, jmcnamara@cpan.org use crate::common; use polars::prelude::*; use polars_excel_writer::PolarsXlsxWriter; use rust_xlsxwriter::XlsxError; // Compare output against target Excel file using PolarsXlsxWriter. fn create_new_xlsx_file(filename: &str) -> Result<(), XlsxError> { let df: DataFrame = df!( "Foo" => &[1, 1, 1], "Bar" => &[2, 2, 2], )?; let mut xlsx_writer = PolarsXlsxWriter::new(); xlsx_writer.set_autofilter(false); xlsx_writer.write_dataframe(&df)?; xlsx_writer.save(filename)?; Ok(()) } #[test] fn dataframe_write_excel12() { let test_runner = common::TestRunner::new() .set_name("dataframe12") .set_function(create_new_xlsx_file) .ignore_calc_chain() .initialize(); test_runner.assert_eq(); test_runner.cleanup(); }