0

I'm using CsvHelper.Excel.ExcelWriter class from Nuget Pack (CsvHelper.Excel.Core).

It works if I only try to write on FileStream, but it doens't on MemoryStream.

It Works

 using (var w = new CsvHelper.Excel.ExcelWriter("C:\\temp\\test.xlsx", CultureInfo.InvariantCulture))
 {
     await w.WriteRecordsAsync<MyItem>(items);
     w.Dispose();
 }

It doesn't work

 var mm = new MemoryStream();
 var w = new CsvHelper.Excel.ExcelWriter(mm, CultureInfo.InvariantCulture, true);
 await w.WriteRecordsAsync<MyItem>(items);
 mm.Flush();
 w.Dispose();

Any suggestions?

2
  • as is the code flushes the memorystream. Have you tried mm.Position=0; instead? What are you doing with the memory? Commented May 23, 2024 at 16:59
  • MemoryStream is empty, Position is 0, Length also. Simply, it doesn't work. It's a bug. Commented May 25, 2024 at 9:43

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.