https://bz.apache.org/bugzilla/show_bug.cgi?id=65543

            Bug ID: 65543
           Summary: RecordFormatException: Not enough data (0) to read
                    requested (2) bytes
           Product: POI
           Version: 5.0.0-FINAL
          Hardware: PC
            Status: NEW
          Severity: major
          Priority: P2
         Component: HSSF
          Assignee: [email protected]
          Reporter: [email protected]
  Target Milestone: ---

Created attachment 38006
  --> https://bz.apache.org/bugzilla/attachment.cgi?id=38006&action=edit
example of files

Hi,

sometimes we get an error for the file that was modified in Excel (Microsoft
Office 365). Library org.apache.poi:poi v5.0.0 (and the same result for other
versions) might have some issue. 

Simple example below to reproduce our issue:

{code}
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.ss.usermodel.Workbook;

import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;

public class CheckXLSReading {
    public static void main(String[] args) throws IOException {
        InputStream inputStream = new FileInputStream("D:\\file_to_check.xls");

        Workbook workbook = new HSSFWorkbook(inputStream);

        System.out.println(workbook);
    }
}
{code}

1) First file file_to_check_365.xls has been modified in "Microsoft Excel for
Microsoft 365 MSO (16.0.14228.20216) 64-bit". And we have the following error
for this file:

Console output
{code}
Exception in thread "main" org.apache.poi.util.RecordFormatException: Not
enough data (0) to read requested (2) bytes
        at
org.apache.poi.hssf.record.RecordInputStream.checkRecordPosition(RecordInputStream.java:246)
        at
org.apache.poi.hssf.record.RecordInputStream.readShort(RecordInputStream.java:265)
        at
org.apache.poi.hssf.record.common.UnicodeString.<init>(UnicodeString.java:77)
        at
org.apache.poi.hssf.record.SSTDeserializer.manufactureStrings(SSTDeserializer.java:57)
        at org.apache.poi.hssf.record.SSTRecord.<init>(SSTRecord.java:235)
        at
org.apache.poi.hssf.record.RecordFactory.createSingleRecord(RecordFactory.java:79)
        at
org.apache.poi.hssf.record.RecordFactoryInputStream.readNextRecord(RecordFactoryInputStream.java:289)
        at
org.apache.poi.hssf.record.RecordFactoryInputStream.nextRecord(RecordFactoryInputStream.java:255)
        at
org.apache.poi.hssf.record.RecordFactory.createRecords(RecordFactory.java:166)
        at
org.apache.poi.hssf.usermodel.HSSFWorkbook.<init>(HSSFWorkbook.java:343)
        at
org.apache.poi.hssf.usermodel.HSSFWorkbook.<init>(HSSFWorkbook.java:399)
        at
org.apache.poi.hssf.usermodel.HSSFWorkbook.<init>(HSSFWorkbook.java:381)
        at CheckXLSReading.main(CheckXLSReading.java:12)
{code}

2) Second file file_to_check_2016.xls has been re-saved from the previous file
only using "Microsoft Excel 2016 (16.0.5188.1000) MSO (16.0.5188.1000) 32-bit".
And after that we don't have any errors.

Console output
{code}
org.apache.poi.hssf.usermodel.HSSFWorkbook@58c1670b
{code}

Could you please check this issue. Thank you in advance!

-- 
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to