Skip to content

Commit

Permalink
#240 support also table[column] syntax
Browse files Browse the repository at this point in the history
PR #312
  • Loading branch information
SoltauFintel authored May 10, 2024
1 parent 6dec5d3 commit a1bb43e
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
3 changes: 3 additions & 0 deletions jxls-site/docs/changes.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# Release Notes

## v3.1.0
- [#240 Table syntax support for AbstractFormulaProcessor.getFormulaCellRefs()](https://github.com/jxlsteam/jxls/issues/240)

## v3.0.0
- Java 17
- see [migration guide](migration-to-v3-0.html)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,11 @@
*/
public abstract class AbstractFormulaProcessor implements FormulaProcessor {
protected static final String regexJointedLookBehind = "(?<!U_\\([^)]{0,100})";
public static final String regexCellRef = "([a-zA-Z_]+[a-zA-Z0-9_]*![a-zA-Z]+[0-9]+|(?<!\\d)[a-zA-Z]+[0-9]+|'[^?\\\\/:'*]+'![a-zA-Z]+[0-9]+)";
private static final String regexCellRefExcludingJointed = regexJointedLookBehind + regexCellRef;
public static final String regexCellRef = "([a-zA-Z_]+[a-zA-Z0-9_]*![a-zA-Z]+[0-9]+" // sheet + cell syntax
+ "|[a-zA-Z_]+[a-zA-Z0-9_]*\\[[a-zA-Z0-9 _]+\\]" // table syntax (#240)
+ "|(?<!\\d)[a-zA-Z]+[0-9]+" // cell syntax
+ "|'[^?\\\\/:'*]+'![a-zA-Z]+[0-9]+)"; // 'sheet name' + cell syntax
public static final String regexCellRefExcludingJointed = regexJointedLookBehind + regexCellRef;
private static final Pattern regexCellRefExcludingJointedPattern = Pattern.compile(regexCellRefExcludingJointed);
private static final Pattern regexCellRefPattern = Pattern.compile(regexCellRef);
private static final String regexJointedCellRef = "U_\\([^\\)]+\\)";
Expand Down
4 changes: 2 additions & 2 deletions jxls/src/test/java/org/jxls/util/UtilTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public void should_return_sheet_names_of_multi_sheet_template() {
assertEquals(sheetsNameOfMultiSheetTemplate, singletonList("areaWithMultiSheetOutput"));
}

// #240 not part of v2.13.0 @Test
@Test
public void test_getFormulaCellRefs_tableSyntax() {
// Test
String table = "_tabu";
Expand All @@ -51,7 +51,7 @@ public void test_getFormulaCellRefs_tableSyntax() {
assertEquals("_tabu[ 1 column b]", formulaCellRefs.get(0));
}

// #240 not part of v2.13.0 @Test
@Test
public void test_getFormulaCellRefs_tableSyntax2() {
// Test
String formula = "FUNC(one[AB CD],two[123], -1, three[c])";
Expand Down

0 comments on commit a1bb43e

Please sign in to comment.