Copilot commented on code in PR #3434:
URL: https://github.com/apache/tika/pull/3434#discussion_r4382789688


##########
tika-parsers/tika-parsers-standard/tika-parsers-standard-modules/tika-parser-microsoft-module/src/main/java/org/apache/tika/parser/microsoft/TikaExcelDataFormatter.java:
##########
@@ -44,13 +44,17 @@ public TikaExcelDataFormatter(Locale locale) {
     @Override
     public String formatRawCellContents(double value, int formatIndex, String 
formatString,
                                         boolean use1904Windowing) {
-        if (DateUtil.isADateFormat(formatIndex, formatString)) {
-            String activeDateFormatString =
-                    (dateOverrideFormatString == null) ? formatString : 
dateOverrideFormatString;
-            return super.formatRawCellContents(value, formatIndex, 
activeDateFormatString,
+        String activeFormatString = formatString;
+        if (dateOverrideFormatString != null && 
DateUtil.isADateFormat(formatIndex, formatString)) {
+            activeFormatString = dateOverrideFormatString;
+        }
+        try {
+            return super.formatRawCellContents(value, formatIndex, 
activeFormatString,
                     use1904Windowing);
-        } else {
-            return super.formatRawCellContents(value, formatIndex, 
formatString, use1904Windowing);
+        } catch (RuntimeException e) {
+            // TODO: remove on POI 6.0.1, whose DataFormatter falls back per 
value itself; 6.0.0
+            // throws from SimpleFraction on overflow for a fraction format 
with text, e.g. #\ ???/???
+            return super.formatRawCellContents(value, 0, "General", 
use1904Windowing);

Review Comment:
   The new XLS regression exercises `ExcelExtractor`'s recovery path, so 
removing this catch would leave the test passing and the shared formatter's 
overflow fallback unprotected. Add a direct `TikaExcelDataFormatter` or XLSX 
regression that formats the valid fraction followed by the overflowing value 
with the same formatter and asserts the General-formatted fallback.



-- 
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]

Reply via email to