Closed reecesavage closed 5 years ago
Hi Thanks for the report. Yes, it is true. In case of a MemoryStream, it would not work. I think this is a follow-up bug , from the fact that in an older version of PicoXLSX, the stream of a file only was closed when the application was terminated. Closing the stream immediatelly after writing was the (quick) fix there. But we can see the result now.
I have not the infrastructure around me to fix it right now. But I can provide a patch within the next 24h, hopefully. If you have the sources, you can fix the problem quite easy:
Just comment out the line 399 in the file LowLevel.cs. Maybe 396 and 397 must be modified as well (I have to check it).
Ah yea I bet commenting out 399 would fix it. I'll wait for a patch though. It isn't critical since I have it working by reading the saved file. Once the fix is in nuget I will rework the code. Thanks man.
Fixed with commit 3f635ad6d9ff1abc17c6d3d9fd40a73b9447b124 SaveAsStream and SaveAsStreamAsync have now bot an optional parameter "leaveOpen".
The NuGet package was deployed and is currently in release process (available in some minutes). NanoXLSX, PicoXLSX4j and NanoXLSX4j will be updated and released soon.
Please let me know, if something is not working as expected.
When using the SaveAsStream Method the Stream is closed. This is mostly ok with a FileStream, but with a MemoryStream you can't read the Stream into something else that accepts a Stream. The Demo's say you can use a MemoryStream, but I'm not sure how you could ever do that. I am using this to create an XLSX from a DataTable and then archive it into a document repo via its API. Since the MemoryStream is closed I can't archive it directly from the Stream. I have to use a FileStream or Save the file which does the same thing. Then read the saved file to archive it. It works with the work around so it isn't critical, but figured I was log it as an issue since the Demo says MemoryStreams are supported. Thanks.
MemoryStream.CanWrite evaluates to false after calling the SaveAsStream method.