jmcnamara / rust_xlsxwriter

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

feature request: support wasm #57

Closed svieujot closed 11 months ago

svieujot commented 11 months ago

Feature Request

Currently it fails when creating a worksheet:

panicked at library/std/src/sys/wasm/../unsupported/time.rs:31:9:
time not implemented on this platform

Stack:

__wbg_get_imports/imports.wbg.__wbg_new_abda76e883ba8a5f@http://127.0.0.1:8080/wingman_ui-ab1b952e4ac40214.js:325:21
console_error_panic_hook::hook::h79ac961f5aab2ea7@http://127.0.0.1:8080/wingman_ui-ab1b952e4ac40214_bg.wasm:wasm-function[2176]:0x2db1f8
core::ops::function::Fn::call::hb648b073a046a4d9@http://127.0.0.1:8080/wingman_ui-ab1b952e4ac40214_bg.wasm:wasm-function[7370]:0x3d7f87
std::panicking::rust_panic_with_hook::h964f5352fba2016e@http://127.0.0.1:8080/wingman_ui-ab1b952e4ac40214_bg.wasm:wasm-function[4196]:0x3956cf
std::panicking::begin_panic_handler::{{closure}}::h716a005a10b672c4@http://127.0.0.1:8080/wingman_ui-ab1b952e4ac40214_bg.wasm:wasm-function[4626]:0x3ab139
std::sys_common::backtrace::__rust_end_short_backtrace::haac356ff17e1eee4@http://127.0.0.1:8080/wingman_ui-ab1b952e4ac40214_bg.wasm:wasm-function[7362]:0x3d7f42
rust_begin_unwind@http://127.0.0.1:8080/wingman_ui-ab1b952e4ac40214_bg.wasm:wasm-function[5496]:0x3c6720
core::panicking::panic_fmt::h8f8677da57cb02fb@http://127.0.0.1:8080/wingman_ui-ab1b952e4ac40214_bg.wasm:wasm-function[5916]:0x3ce379
std::time::SystemTime::now::h0483490d67579cfa@http://127.0.0.1:8080/wingman_ui-ab1b952e4ac40214_bg.wasm:wasm-function[5914]:0x3ce2f8
rust_xlsxwriter::datetime::ExcelDateTime::utc_now::hcaed1ef12b7c4468@http://127.0.0.1:8080/wingman_ui-ab1b952e4ac40214_bg.wasm:wasm-function[604]:0x1c0439
rust_xlsxwriter::workbook::Workbook::new::h7ccd5d2417379d72@http://127.0.0.1:8080/wingman_ui-ab1b952e4ac40214_bg.wasm:wasm-function[1984]:0x2c0989
...

Replacing std::time::SystemTime with chrono will probably fix the problem as chrono works with web assembly.

jmcnamara commented 11 months ago

Some questions:

  1. What version of rustc are you using?
  2. What version of rust_xlsxwriter are you using?
  3. What rust_xlsxwriter feature flags are you using?
  4. Are you using the rust_xlsxwriter wasm flag?
  5. What wasm compiler or compilation method are you using (node, browser, deno, wasmtime, other)?
  6. Could you try the example here: https://github.com/Clipi-12/rust_xlsx_wasm_example and let me know if it works?
  7. Could you post a minimal working example that demonstrates the issue.
svieujot commented 11 months ago

All my apologies, I did not configure the wasm flag.

Work great with this flag !

Thank you.

jmcnamara commented 11 months ago

Work great with this flag

Great. Just for the record what wasm method are you using?