i cannot open a file with npoi
weifan999 opened this issue · comments
NPOI Version
2.7.0
File Type
- XLSX
using var fs = new FileStream(filename, FileMode.Open, FileAccess.ReadWrite, FileShare.None);
IWorkbook wb = new XSSFWorkbook(fs);
When I execute the second sentence, the following error occurs:
When I open the workbook and do nothing and click save, an error occurs when I execute the above code. When I deleted all the blank lines below, it returned to normal.
Please provide the xlsx file.
here are the file
合约台账 - 副本.xlsx
In styles.xml, there are two tableStyle with same name 'TableStylePreset3_Accent1'. There is nothing wrong with NPOI exception. Please double check your file.
<tableStyles count="3" defaultTableStyle="TableStylePreset3_Accent1" defaultPivotStyle="PivotStylePreset2_Accent1">
<tableStyle name="TableStylePreset3_Accent1" pivot="0" count="7" xr9:uid="{59DB682C-5494-4EDE-A608-00C9E5F0F923}">
<tableStyleElement type="wholeTable" dxfId="6"/>
<tableStyleElement type="headerRow" dxfId="5"/>
<tableStyleElement type="totalRow" dxfId="4"/>
<tableStyleElement type="firstColumn" dxfId="3"/>
<tableStyleElement type="lastColumn" dxfId="2"/>
<tableStyleElement type="firstRowStripe" dxfId="1"/>
<tableStyleElement type="firstColumnStripe" dxfId="0"/>
</tableStyle>
<tableStyle name="TableStylePreset3_Accent1" pivot="0" table="0" count="7" xr9:uid="{709FE4E6-EA37-494D-900A-CBBD63CA84A4}">
<tableStyleElement type="wholeTable" dxfId="6"/>
<tableStyleElement type="headerRow" dxfId="5"/>
<tableStyleElement type="totalRow" dxfId="4"/>
<tableStyleElement type="firstColumn" dxfId="3"/>
<tableStyleElement type="lastColumn" dxfId="2"/>
<tableStyleElement type="firstRowStripe" dxfId="1"/>
<tableStyleElement type="firstColumnStripe" dxfId="0"/>
</tableStyle>
<tableStyle name="PivotStylePreset2_Accent1" table="0" count="10" xr9:uid="{267968C8-6FFD-4C36-ACC1-9EA1FD1885CA}">
<tableStyleElement type="headerRow" dxfId="22"/>
<tableStyleElement type="totalRow" dxfId="21"/>
<tableStyleElement type="firstRowStripe" dxfId="20"/>
<tableStyleElement type="firstColumnStripe" dxfId="19"/>
<tableStyleElement type="firstSubtotalRow" dxfId="18"/>
<tableStyleElement type="secondSubtotalRow" dxfId="17"/>
<tableStyleElement type="firstRowSubheading" dxfId="16"/>
<tableStyleElement type="secondRowSubheading" dxfId="15"/>
<tableStyleElement type="pageFieldLabels" dxfId="14"/>
<tableStyleElement type="pageFieldValues" dxfId="13"/>
</tableStyle>
</tableStyles>
I modified the style.xml of the file, and the code runs normally. However, when I open the xlsx file, nothing is done. After clicking Save, this error will appear again when executing NPOI.
It's very strange, so I mentioned it at the beginning, to open a worksheet, do nothing, just click save, and then close. An error will be reported when executing npoi code