jmcnamara / rust_xlsxwriter

A Rust library for creating Excel XLSX files.
https://crates.io/crates/rust_xlsxwriter
Apache License 2.0
316 stars 25 forks source link

Announce: major API change in the next release #9

Closed jmcnamara closed 1 year ago

jmcnamara commented 1 year ago

In the next release (0.9.0) there is a major change to the constructor and destructor methods.

The API will change from having the filename in the constructor like this:

fn main() -> Result<(), XlsxError> {
    let mut workbook = Workbook::new("workbook.xlsx");

    _ = workbook.add_worksheet();

    workbook.close()?;

    Ok(())
}

To having a workbook::new() without filename and a workbook.save() with a filename instead of a workbook.close(). LIke this:


fn main() -> Result<(), XlsxError> {
    let mut workbook = Workbook::new();

    _ = workbook.add_worksheet();

    workbook.save("workbook.xlsx")?;

    Ok(())
}

There will also be workbook.save_to_buffer() and workbook.save_to_path() methods.

This simplifies the constructor/destructor sequence and introduces a save() option that was often requested in the Python version but which I never implemented.

This is quite an invasive change on previous versions and I apologies for the inconvenience, but there is still a relatively small number of active users so it is best to make this change now.