[ 
https://issues.apache.org/jira/browse/NIFI-16429?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18130949#comment-18130949
 ] 

Daniel Stieglitz commented on NIFI-16429:
-----------------------------------------

It appears from the latest release of POI 6.0.0 that DataFormatter now uses 
cached values for formula cells by default hence it not necessary to actually 
call  setUseCachedValuesForFormulaCells as was done in the fix for this ticket 
in PR #11820. Hence, once NIFI starts using POI 6.0.0 we could revert the 
change.

> ExcelReader - "Use Starting Row" strategy doesn't evaluate formulas for 
> Header Row
> ----------------------------------------------------------------------------------
>
>                 Key: NIFI-16429
>                 URL: https://issues.apache.org/jira/browse/NIFI-16429
>             Project: Apache NiFi
>          Issue Type: Bug
>            Reporter: Philipp Korniets
>            Assignee: Daniel Stieglitz
>            Priority: Major
>             Fix For: 2.13.0
>
>         Attachments: test_book.xlsx
>
>          Time Spent: 20m
>  Remaining Estimate: 0h
>
> When processing this workbook, header in Second Sheet contains formula.
> ="value_in_"&'First Sheet'!B1
> Previously, ConvertExcelToCSV was returning last cached value. However in new 
> ExcelReader value comes from DataFormatter and not from getCellValue() for 
> strategy  *Use Starting Row*
> So the result looks wrong i think
> {code:java}
> test_col1,"\"value_in_\"&'First Sheet'!B1",test_col3{code}
> AI details:
> *{{ExcelReader.java}}* ({{{}getSchemaAccessStrategy{}}}, about lines 
> 177–186): for "Use Starting Row" it builds {{{}new 
> ExcelStartingRowSchemaInference(...){}}}.
>  
> java
> {code:java}
> if 
> (ExcelStartingRowSchemaInference.USE_STARTING_ROW.getValue().equals(allowableValue))
>  {
>     ...
>     final SchemaInferenceEngine<Row> inference =
>             new ExcelStartingRowSchemaInference(rowEvaluationStrategy, 
> firstRow, createTimeValueInference());
>     return createInferSchemaAccessStrategy(context, inference); {code}
> *{{{}ExcelStartingRowSchemaInference.java{}}}:*
> ||Approx. line||Code||
> |52|{{private final DataFormatter dataFormatter;}}|
> |58|{{this.dataFormatter = new DataFormatter();}} (constructor, plain, no 
> evaluator, no {{{}setUseCachedValuesForFormulaCells{}}})|
> |71|{{fieldNames = getFieldNames(firstRow, row);}} (in {{{}inferSchema{}}}, 
> when {{{}index == 0{}}})|
> |*103*|*{{final String fieldName = dataFormatter.formatCellValue(cell);}}* 
> (in {{{}getFieldNames{}}})|
> Line 103 is the one that returns the formula text on POI 5.x. The header row 
> is the first row the inference loop reads, so {{getFieldNames()}} gets it at 
> line 71.



--
This message was sent by Atlassian Jira
(v10.3.26#10030026)

Reply via email to