jmcnamara / libxlsxwriter

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

Add buffer support #382

Closed mohd-akram closed 1 year ago

mohd-akram commented 1 year ago

This extends the realm of USE_FMEMOPEN to all temporary files, which is accomplished by using open_memstream. It also adds two new workbook options, output_buffer and output_buffer_size, to allow outputting to a buffer when filename is NULL. This allows the library to be used without writing to the filesystem.

jmcnamara commented 1 year ago

Thanks. You did a pretty good job on this.

I have some comments that you can fix up before merge or I can fix them afterwards. I'll make the comments inline/in review.

mohd-akram commented 1 year ago

@jmcnamara Thanks for the kind comments, I was trying to maintain the same quality level as the rest of the code base, which is pretty high! I've applied all your suggestions except for changing the order of the fields in the options struct. If you wish to proceed with this it will also require changes in some of the tests (they should probably be changed to use named fields). Maybe this can be done separately after the PR since it's a breaking API change.

jmcnamara commented 1 year ago

I've applied all your suggestions except for changing the order of the fields in the options struct.

Fair point.

it will also require changes in some of the tests (they should probably be changed to use named fields)

As far as I remember the tests don't use named fields for ANSIC compatibility (i.e., older versions of MSVC on Windows).

jmcnamara commented 1 year ago

Merged. Thanks.

jmcnamara commented 1 year ago

Added in version 1.1.5.