Skip to content

#240 table syntax #312

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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