ongdisheng commented on code in PR #693:
URL: https://github.com/apache/fesod/pull/693#discussion_r2534892014


##########
fesod/src/main/java/org/apache/fesod/sheet/analysis/v07/handlers/CellFormulaTagHandler.java:
##########
@@ -34,18 +42,89 @@ public class CellFormulaTagHandler extends 
AbstractXlsxTagHandler {
     public void startElement(XlsxReadContext xlsxReadContext, String name, 
Attributes attributes) {
         XlsxReadSheetHolder xlsxReadSheetHolder = 
xlsxReadContext.xlsxReadSheetHolder();
         xlsxReadSheetHolder.setTempFormula(new StringBuilder());
+
+        String formulaType = 
attributes.getValue(ExcelXmlConstants.ATTRIBUTE_T);
+        String sharedIndex = 
attributes.getValue(ExcelXmlConstants.ATTRIBUTE_SI);
+
+        xlsxReadSheetHolder.setTempFormulaType(formulaType);
+        xlsxReadSheetHolder.setTempFormulaSharedIndex(sharedIndex != null ? 
Integer.parseInt(sharedIndex) : null);
     }

Review Comment:
   Thanks for the suggestion! I checked the codebase and found that 
`Integer.parseInt` is used without try-catch in similar XML parsing contexts 
such as 
[CellTagHandler.java:66](https://github.com/apache/fesod/blob/efe89d7026f190c2a5b393ad8efb4eb983dd7b88/fesod/src/main/java/org/apache/fesod/sheet/analysis/v07/handlers/CellTagHandler.java#L66).
 Meanwhile, according to the [Office Open 
XML](https://c-rex.net/samples/ooxml/e1/Part4/OOXML_P4_DOCX_f_topic_ID0E6TY4.html)
 standard, the `si` attribute is defined as:
   ```
   <attribute name="si" type="xsd:unsignedInt" use="optional"/>
   ```
   The spec guarantees `si` is always an unsigned integer in valid Excel files. 
If it contains an invalid value, the Excel file is malformed and the 
`NumberFormatException` should propagate to fail fast rather than silently 
swallowing the error.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to