jmcnamara / libxlsxwriter

A C library for creating Excel XLSX files.
https://libxlsxwriter.github.io
Other
1.49k stars 332 forks source link

Improve buffer support #383

Closed mohd-akram closed 1 year ago

mohd-akram commented 1 year ago

macOS does not like rewinding and reading from a memstream (it messes up the buffer) which is fair enough - per spec, open_memstream() returns a write-only stream. This PR ensures the buffer is read from directly to avoid this.

jmcnamara commented 1 year ago

Merged. Thanks.

jmcnamara commented 1 year ago

I'll probably need to change the lxw_get_filehandle() call back to a simple lxw_tmpfile() in the worksheet memory optimization initialization since if the user requests minimum memory usage then it doesn't make sense to store the file in memory.

https://github.com/jmcnamara/libxlsxwriter/blob/main/src/worksheet.c#L195

I'll add some explanation in the doc. No action needed on your side.

Thanks once more. If you are using this in-memory functionality in an app then let me know how you get on.

mohd-akram commented 1 year ago

I'll probably need to change the lxw_get_filehandle() call back to a simple lxw_tmpfile() in the worksheet memory optimization initialization since if the user requests minimum memory usage then it doesn't make sense to store the file in memory.

That definitely makes sense.

Thanks once more. If you are using this in-memory functionality in an app then let me know how you get on.

I have published the initial version of my project, excelwriter, Node.js bindings for the library, which is what I needed the changes for. Thank you for this great project!

jmcnamara commented 1 year ago

I have published the initial version of my project, excelwriter, Node.js bindings for the library

That is pretty cool. Does that use wasm or something else?

mohd-akram commented 1 year ago

It does not, it uses Node-API, more specifically the C++ wrapper around it. I would have to look into WASM to get it running in a browser, which should theoretically be possible, but I've never done it before.