NPOI Excel creating corrupt xls files

Jul 15, 2014 at 6:48 AM
I am trying to fill in a template xls with values, but even just opening with NPOI and saving as new file creates a corrupt xls.
There are a lot of things happening in the template, its locked, so I cannot alter anything to find the cause.
You can download the template here:
xls file

Heres the code I am using to open and save:
private void btnNPOITest_Click(object sender, EventArgs e)
            string templatePath = "C:\\Test\\MyTemplate.xls";
            string outputPath = "C:\\Test\\" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".xls";
            FileStream inFile = new FileStream(templatePath, FileMode.Open, FileAccess.Read);
            NPOI.HSSF.UserModel.HSSFWorkbook workBook = new NPOI.HSSF.UserModel.HSSFWorkbook(inFile);
            NPOI.SS.UserModel.ISheet sheet1 = workBook.GetSheet("Sheet1");

            FileStream outFile = new FileStream(outputPath, FileMode.Create);