NPOI - Writing to file corrupts .xlsx workbook
<p>I have a piece of code that is currently writes to a <code>.xls</code> workbook (<code>HSSFWorkbook</code>) with no issue.  However when I try to use the same code to write to a <code>.xlsx</code> workbook (<code>XSSFWorkbook</code>) the archive becomes corrupted and cannot be opened in excel.</p>

<p>The following code is what I am using to access the workbook, edit the workbook, and then save back to the workbook.  I originally assumed that the code that I was using to edit the workbook was the issue, but after commenting it out the issue still persists.</p>

<pre><code>IWorkbook workbook;
using (var file = new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
{
    if (Path.GetExtension(fileName).Contains("xlsx"))
    {
        workbook = new XSSFWorkbook(file);
    }
    else
    {
        workbook = new HSSFWorkbook(file);
    }
}

//Code that edits workbook which is currently commented out

using (var file = new FileStream(path, FileMode.Open, FileAccess.ReadWrite))
{
    workbook.Write(file);
}
</code></pre>

<p>I have tried running this code against a blank <code>.xlsx</code> workbook and the file becomes corrupt, and is no longer able to be opened.</p>

<p>I am using the latest stable version of NPOI from nuget: <code>NPOI 2.1.3.1</code></p>