NPOI.HSSF.Record.LeftoverDataException: Initialisation of record 0x31 left 4 bytes remaining still t

NPOI在导入excel文件的时候,会出现如下错误:
NPOI.HSSF.Record.LeftoverDataException: Initialisation of record 0x31 left 4 bytes remaining still to be read.
但是用excel能够正常打开,并且在excel中保存后,可以正常的导入,找到原因和方法如下:
原因(链接地址
NPOI.HSSF.Record.LeftoverDataException: Initialisation of record 0x31 left 4 bytes remaining still t
解决方案:
NPOI.HSSF.Record.LeftoverDataException: Initialisation of record 0x31 left 4 bytes remaining still t
代码如下图:
NPOI.HSSF.Record.LeftoverDataException: Initialisation of record 0x31 left 4 bytes remaining still t

不再抛出异常,加了readToEndOfRecord();方法。

但是又抛出了异常:
System.InvalidOperationException: Found EOFRecord before WindowTwoRecord was encountered

接下来是比较流氓的一步操作了:
NPOI.HSSF.Record.LeftoverDataException: Initialisation of record 0x31 left 4 bytes remaining still t
直接修改了NPOI.HSSF.Model.RecordOrderer.IsEndOfRowBlock,注释掉 //throw new InvalidOperationException(“Found EOFRecord before WindowTwoRecord was encountered”);直接改为return true;

这样就可以正常导入了。