Search code examples
c#npoi

NPOI is generating a 0 bytes stream


I am using a C# code that works perfectly in other projects.... but in this one, it is returning a 0 bytes length stream.

This is how I am saving the stream:

        using (var exportData = new MemoryStream())
        {
            workbook.Write(exportData);
            return exportData.ToArray();
        }

workbook is correctly formed, and in fact, as I have told you, this code works in other projects.

In this case, I am using NPOI 2.4.0 and SharpZipLib 0.86.0. I have found similar issues telling that the problem is SharpZipkib version, but this is not my case.

What else can this be causing the problem? It is a shame that NPOI does not even send any exception.

Regards Jaime


Solution

  • The problem was the SharpZipLib version definition in web.config.

    The solution was explained in my other question here which I posted an answer myself.