nissl-lab / npoi

a .NET library that can read/write Office formats without Microsoft Office installed. No COM+, no interop.
Apache License 2.0
5.65k stars 1.42k forks source link

i cannot open a file with npoi #1339

Closed weifan999 closed 3 months ago

weifan999 commented 3 months ago

NPOI Version

2.7.0

File Type

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.

tonyqus commented 3 months ago

Please provide the xlsx file.

weifan999 commented 3 months ago

here are the file 合约台账 - 副本.xlsx

tonyqus commented 3 months ago

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>
weifan999 commented 3 months ago

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.

weifan999 commented 3 months ago

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