jxls icon indicating copy to clipboard operation
jxls copied to clipboard

Table syntax support for Util.getFormulaCellRefs()

Open SoltauFintel opened this issue 1 year ago • 3 comments

Using German formula =SUMMEWENNS(AktuellerBestandTabelle[Buchwert_Direkt];AktuellerBestandTabelle[Zinsblock ohne 71_72];WAHR;AktuellerBestandTabelle[Erste Fälligkeit Jahr];0) will result in wrong value 0.

Cause is this code in StandardFormulaProcessor.java:116:

if (isFormulaCellRefsEmpty && isFormulaJointedCellRefsEmpty
   && (!formulaCellData.isParameterizedFormulaCell() || formulaCellData.isJointedFormulaCell())) {
         targetFormulaString = formulaCellData.getDefaultValue() != null ? formulaCellData.getDefaultValue() : "0";
}

isFormulaCellRefsEmpty is true because JXLS doesn't recognize the table syntax (e.g. "AktuellerBestandTabelle[Buchwert_Direkt]") as a cell ref. Util.getFormulaCellRefs returns an empty list.

SoltauFintel avatar Mar 30 '23 15:03 SoltauFintel

Solution: extend Utl.regexCellRef with + "|[a-zA-Z_]+[a-zA-Z0-9_]*\\[.+\\]". However, many testcases will fail.

SoltauFintel avatar Mar 30 '23 15:03 SoltauFintel

Solution: extend Utl.regexCellRef with + "|[a-zA-Z_]+[a-zA-Z0-9_]*\\[.+\\]". However, many testcases will fail.

I added |[a-zA-Z_]+[a-zA-Z0-9_]*\[.+\] to the Util.regexCellRef pattern as you suggested and mvn verify still works fine for me. So I committed the change to the feature-240 branch.

leonate avatar Apr 07 '23 21:04 leonate

Formula "FUNC(a[b],c[d])" does not work. I'm going to push a bugfix.

SoltauFintel avatar Jul 05 '23 12:07 SoltauFintel

PR #312 is my 2nd attempt to solve this issue.

SoltauFintel avatar May 10 '24 08:05 SoltauFintel