// SPDX-License-Identifier: MIT OR Apache-2.0 // // Copyright 2023-2024, John McNamara, jmcnamara@cpan.org //! An example of writing a Polar Rust dataframe to an Excel file. This //! demonstrates saving the dataframe without a header. use polars::prelude::*; fn main() { // Create a sample dataframe for the example. let mut df: DataFrame = df!( "String" => &["North", "South", "East", "West"], "Int" => &[1, 2, 3, 4], "Float" => &[1.0, 2.22, 3.333, 4.4444], ) .unwrap(); example(&mut df).unwrap(); } use polars_excel_writer::ExcelWriter; fn example(df: &mut DataFrame) -> PolarsResult<()> { let mut file = std::fs::File::create("dataframe.xlsx").unwrap(); ExcelWriter::new(&mut file).has_header(false).finish(df) }