Open yoliva opened 1 year ago
@yoliva
I have found a solution.
The data is transferred to the stream during Dispose
.
But for some reason the Dispose is executed too late.
If you call it manually before fetching the BinaryArray, the data is there.
using var stream = new MemoryStream();
using var writer = new ExcelWriter(stream, CultureInfo.InvariantCulture);
{
writer.WriteRecords(sections.ToList());
}
// ------------------------------------------------
writer.Dispose(); // The daten will transfer to the stream
// ------------------------------------------------
var data = stream.ToArray();
var fileName = $"{DateTime.UtcNow.ToStandardFullFormat()}.{FileExtensions.XLSX}";
return new DataFile(fileName, ContentTypes.XLSX, FileType, data);
This hack
is working in my case.
Hi, I'm unable to get the bytes of the xlsx file from the MemoryStream. the code in approach 1 generates the file but in approach 2 I get always an empty byte[]. What I'm missing here? thanks!