[
https://issues.apache.org/jira/browse/TIKA-4993?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18132633#comment-18132633
]
ASF GitHub Bot commented on TIKA-4993:
--------------------------------------
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.
> Update to POI 6.0.0
> -------------------
>
> Key: TIKA-4993
> URL: https://issues.apache.org/jira/browse/TIKA-4993
> Project: Tika
> Issue Type: Improvement
> Components: parser
> Reporter: Tilman Hausherr
> Priority: Minor
>
--
This message was sent by Atlassian Jira
(v10.3.26#10030026)