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:
The code is here:
FileStream readFile = new FileStream(templatePath, FileMode.Open, FileAccess.Read);
XSSFWorkbook xssfworkbook = new XSSFWorkbook(readFile);
readFile.Close();
FileStream writeFile = new FileStream(outputPath, FileMode.Create, FileAccess.Write);
xssfworkbook.Write(writeFile);
writeFile.Close();
You can see I didn't make any changes to the template, but those pivotTable will still be disappeared in the new file.