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

question: Why can't I pass u64 to `write()`? #52

Closed MordechaiHadad closed 11 months ago

MordechaiHadad commented 11 months ago

Question

Is there any particular reason write() doesn't allow the passing of u64?

jmcnamara commented 11 months ago

Is there any particular reason write() doesn't allow the passing of u64?

The fundamental reason is that u64 isn't support by Excel.

All Excel numbers are stored in f64 so u64 can't be supported. All the other integer types will convert Into f64 so they are handled.

Generally Excel users are constrained to storing u64 style values as strings.

MordechaiHadad commented 11 months ago

Oh fair enough, thank you for the quick response.

jmcnamara commented 7 months ago

I've been thinking recently about supporting u64/i64 within the limits of Excel's support. So basically u64/i64 would be accepted by write() but stored as f64 like in Excel. This would be a lossy conversion outside +/- 999,999,999,999,999 but for most users that would be okay.

Would that work for the use case you enquired about?

MordechaiHadad commented 7 months ago

Yeah that sounds like a good solution, but personally for me f64 suffices at this point lol.

jmcnamara commented 7 months ago

Thanks for the feedback. I'll put that in the next release.

jmcnamara commented 7 months ago

This support is on main now and will be in the next release.