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;

这样就可以正常导入了。

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-07-28
  • 2022-12-23
  • 2021-07-02
  • 2021-10-05
  • 2021-09-01
  • 2022-12-23
猜你喜欢
  • 2021-08-04
  • 2022-12-23
  • 2021-07-29
  • 2022-01-27
  • 2022-02-18
相关资源
相似解决方案