This project is read-only.

Error reading .xlsm file with pivotTable

Aug 2, 2013 at 11:46 AM
Edited Aug 2, 2013 at 11:49 AM
I have a template .xlsm file with two pivotTable in sheet2 and sheet3. If I read the file with NPOI, and save it to another path(without any changes), those pivotTable cannot be reopened again. To be specific, when I opened the new file, it will report crash and begin auto fixing. After the fixing, only some string left in sheet2 and sheet3, with no table left.

The code is here:
        FileStream readFile = new FileStream(templatePath, FileMode.Open, FileAccess.Read);

        XSSFWorkbook xssfworkbook = new XSSFWorkbook(readFile);


        FileStream writeFile = new FileStream(outputPath, FileMode.Create, FileAccess.Write);


You can see I didn't make any changes to the template, but those pivotTable will still be disappeared in the new file.