Bug 66827 - Exception on loading Excel xslx-file with cell comment
Summary: Exception on loading Excel xslx-file with cell comment
Status: NEW
Alias: None
Product: POI
Classification: Unclassified
Component: POI Overall (show other bugs)
Version: 5.2.3-FINAL
Hardware: PC All
: P2 normal (vote)
Target Milestone: ---
Assignee: POI Developers List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2023-07-31 18:20 UTC by mg.forum
Modified: 2023-08-02 08:58 UTC (History)
1 user (show)



Attachments
Eclipse demo project (19.10 KB, application/octet-stream)
2023-08-01 19:20 UTC, mg.forum
Details

Note You need to log in before you can comment on or make changes to this bug.
Description mg.forum 2023-07-31 18:20:38 UTC
Steps to reproduce:
1. Create cell comment in Excel.
2. Example xl/comment1.xml extracted from xslx (formatted):
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<comments xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main">
  <authors>
    <author>Author</author>
  </authors>
  <commentList>
    <comment ref="A3" authorId="0">
      <text>
        <r>
          <rPr>
            <b />
            <sz val="9" />
            <color indexed="81" />
            <rFont val="Tahoma" />
            <charset val="1" />
          </rPr>
          <t>AGNC via Excel</t>
        </r>
      </text>
    </comment>
  </commentList>
</comments>
3. Load this Excel file via POI.
4. Exception thrown on loading this cell comment:
Exception in thread "Thread-2" org.apache.xmlbeans.impl.values.XmlValueOutOfRangeException: string value 'Text' is not a valid enumeration value for ST_ObjectType in namespace urn:schemas-microsoft-com:office:excel
	at org.apache.xmlbeans.impl.values.JavaStringEnumerationHolderEx.set_text(JavaStringEnumerationHolderEx.java:40)
	at org.apache.xmlbeans.impl.values.XmlObjectBase.update_from_wscanon_text(XmlObjectBase.java:1121)
	at org.apache.xmlbeans.impl.values.XmlObjectBase.check_dated(XmlObjectBase.java:1250)
	at org.apache.xmlbeans.impl.values.JavaStringEnumerationHolderEx.getEnumValue(JavaStringEnumerationHolderEx.java:60)
	at com.microsoft.schemas.office.excel.impl.CTClientDataImpl.getObjectType(CTClientDataImpl.java:14177)
	at org.apache.poi.xssf.usermodel.XSSFVMLDrawing.matchCommentShape(XSSFVMLDrawing.java:304)
	at org.apache.poi.xssf.usermodel.XSSFVMLDrawing.findCommentShape(XSSFVMLDrawing.java:285)
	at org.apache.poi.xssf.model.CommentsTable.findCellComment(CommentsTable.java:198)
	at org.apache.poi.xssf.usermodel.XSSFSheet.getCellComment(XSSFSheet.java:813)
	at org.apache.poi.xssf.usermodel.XSSFCell.getCellComment(XSSFCell.java:1010)
        . . .
Comment 1 Dominik Stadler 2023-08-01 08:23:44 UTC
Can you provide some self-sufficient sample code which creates the file and then demonstrates the problem? Or at least a sample file? 

This would make it much easier for others to reproduce the issue.
Comment 2 mg.forum 2023-08-01 19:20:19 UTC
Created attachment 38707 [details]
Eclipse demo project

Thanks for quick response.

The attached Eclipse project has two demo JUnit tests: one which runs OK and another with EXCEPTION.

The first one I created from scratch - and it worked!
Another is crafted from my minimized code with exception present.
The critical code seems to be identical in both...

Option to try: remove comment from cell in ExcelDemo-EXCEPTION.xlsx and the file will load without exception.
Comment 3 PJ Fanning 2023-08-01 20:51:05 UTC
added test in r1911399

this test passes so the issue is not reproduced

bug66827.xlsx is the 'excpetion' xlsx from the attachment
Comment 5 PJ Fanning 2023-08-02 08:47:46 UTC
So the issue is not with the comments table. It is with the VML Drawing XML.

xl/drawings/vmlDrawing1.vml

has this

<x:ClientData ObjectType="Text">

and this is what is not parsing
Comment 6 PJ Fanning 2023-08-02 08:51:03 UTC
According the XSD that POI was built with, only these Object Types are valid.

    Enum BUTTON = Enum.forString("Button");
    Enum CHECKBOX = Enum.forString("Checkbox");
    Enum DIALOG = Enum.forString("Dialog");
    Enum DROP = Enum.forString("Drop");
    Enum EDIT = Enum.forString("Edit");
    Enum G_BOX = Enum.forString("GBox");
    Enum LABEL = Enum.forString("Label");
    Enum LINE_A = Enum.forString("LineA");
    Enum LIST = Enum.forString("List");
    Enum MOVIE = Enum.forString("Movie");
    Enum NOTE = Enum.forString("Note");
    Enum PICT = Enum.forString("Pict");
    Enum RADIO = Enum.forString("Radio");
    Enum RECT_A = Enum.forString("RectA");
    Enum SCROLL = Enum.forString("Scroll");
    Enum SPIN = Enum.forString("Spin");
    Enum SHAPE = Enum.forString("Shape");
    Enum GROUP = Enum.forString("Group");
    Enum RECT = Enum.forString("Rect");
Comment 7 PJ Fanning 2023-08-02 08:58:59 UTC
I added a workaround in r1911407