jmcnamara / rust_xlsxwriter

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

feature request: please add support for `Result<T, E>` to `IntoExcelData` #64

Closed lucatrv closed 6 months ago

lucatrv commented 6 months ago

Feature Request

Currently IntoExcelData supports Option<T>, which can be used when a value maybe present or not. However often when dealing with tabular data we need to define fallback types, for instance a column could normally contain an f64 but may sometimes contain a String. I think the best way to deal with this very common occurrence is to use Result<f64, String>. Of course also other use cases can be envisioned for a Result<T, E> type. The rust_xlsxwriter::Worksheet::write* methods should correctly write Result<T, E> if both T and E are supported types.

jmcnamara commented 6 months ago

I'm not, at first glance, convinced of the general utility of this.

However, I'll consider it and if anyone else thinks this would be useful then a +1 or "me too" comment will help persuade me.

lucatrv commented 6 months ago

I add references to related discussions for rust-csv and calamine.

jmcnamara commented 6 months ago

Ok. It seems like you have a plan you are working to.

I've added this to main. Let me know how you get on.

It is undocumented for now. I'll add that later. Done.

lucatrv commented 6 months ago

Thanks @jmcnamara , yes I will let you know if this feature can be added to rust-csv and calamine, as it will ease management of invalid field formats.

jmcnamara commented 6 months ago

This feature has been pushed to crates.io in rust_xlsxwriter v0.60.0.