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

            Bug ID: 66319
           Summary: Cell.getCellComment or Cell.removeCellComment cause
                    specific excel fail to write
           Product: POI
           Version: unspecified
          Hardware: PC
            Status: NEW
          Severity: critical
          Priority: P2
         Component: HSSF
          Assignee: dev@poi.apache.org
          Reporter: nk...@rationalenterprise.com
  Target Milestone: ---

Created attachment 38422
  --> https://bz.apache.org/bugzilla/attachment.cgi?id=38422&action=edit
Example excel where this problem occurs

I have an excel file that when iterating through and even just calling
getCellComment throws an exception when I try to write it out. I have attached
an example excel.

The exception is:

class org.apache.poi.hssf.record.DSFRecord cannot be cast to class
org.apache.poi.hssf.record.TabIdRecord (org.apache.poi.hssf.record.DSFRecord
and org.apache.poi.hssf.record.TabIdRecord are in unnamed module of loader
'app')

I am using POI 5.2.3.

Here is some code that can be used to reproduce the error:

try (FileInputStream fileInputStream = new FileInputStream(Path.of("put path to
xls here").toFile());
             Workbook workbook = new HSSFWorkbook(fileInputStream)) {

            for (Sheet sheet : workbook) {
                for (Row row : sheet) {
                    for (Cell cell : row) {
                        cell.getCellComment(); // or even
cell.removeCellComment();
                    }
                }
            }

            FileOutputStream fos = new
FileOutputStream(Files.createTempFile("modified", ".xsl").toFile());
            workbook.write(fos);
            fos.close();
        } catch (Exception e) {
            System.out.println(e.getMessage());
        }

-- 
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@poi.apache.org
For additional commands, e-mail: dev-h...@poi.apache.org

Reply via email to