You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@poi.apache.org by ce...@apache.org on 2025/10/06 05:42:20 UTC
(poi) branch trunk updated (79d1630374 -> ea74954fcf)
This is an automated email from the ASF dual-hosted git repository.
centic pushed a change to branch trunk
in repository https://gitbox.apache.org/repos/asf/poi.git
from 79d1630374 Prevent NullPointerException in XWPFTable.getWidthType(). (#912)
new f10f164c61 Add a microBenchmark for replacing strings
new dc2cfe0bfc Apply IDE suggestions
new 7003357b79 TestAllFiles: Add output if a file cannot be matched to a handler
new 42193c57e4 Try to verify handling of deeply nested xlsx
new b5221fac25 Add changelog
new ea74954fcf Trigger reading metadata-text as part of integration testing
The 6 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
Summary of changes:
.../org/apache/poi/integration/TestXLSX2CSV.java | 89 ++++++++++++++++++++-
.../org/apache/poi/stress/AbstractFileHandler.java | 5 +-
.../java/org/apache/poi/stress/TestAllFiles.java | 6 ++
.../poi/xssf/streaming/DeferredSXSSFWorkbook.java | 10 +--
.../apache/poi/ss/formula/TestEvaluationCache.java | 58 +++++++-------
src/documentation/content/xdocs/changes.xml | 2 +
test-data/spreadsheet/deep-data.xlsx | Bin 0 -> 964835 bytes
test-data/spreadsheet/stress.xls | Bin 73216 -> 73728 bytes
8 files changed, 131 insertions(+), 39 deletions(-)
create mode 100644 test-data/spreadsheet/deep-data.xlsx
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@poi.apache.org
For additional commands, e-mail: commits-help@poi.apache.org
(poi) 02/06: Apply IDE suggestions
Posted by ce...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
centic pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/poi.git
commit dc2cfe0bfce4d87dcf8ae72737bde4d2e96d7590
Author: Dominik Stadler <do...@gmx.at>
AuthorDate: Mon Apr 21 20:20:35 2025 +0200
Apply IDE suggestions
---
.../poi/xssf/streaming/DeferredSXSSFWorkbook.java | 10 ++--
.../apache/poi/ss/formula/TestEvaluationCache.java | 58 +++++++++++-----------
2 files changed, 32 insertions(+), 36 deletions(-)
diff --git a/poi-ooxml/src/main/java/org/apache/poi/xssf/streaming/DeferredSXSSFWorkbook.java b/poi-ooxml/src/main/java/org/apache/poi/xssf/streaming/DeferredSXSSFWorkbook.java
index 5844eb9800..36c367e3c9 100644
--- a/poi-ooxml/src/main/java/org/apache/poi/xssf/streaming/DeferredSXSSFWorkbook.java
+++ b/poi-ooxml/src/main/java/org/apache/poi/xssf/streaming/DeferredSXSSFWorkbook.java
@@ -30,7 +30,7 @@ import org.apache.poi.xssf.usermodel.XSSFSheet;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
/**
- * An variant of SXSSFWorkbook that avoids generating a temporary file and writes data directly to
+ * A variant of SXSSFWorkbook that avoids generating a temporary file and writes data directly to
* the provided OutputStream.
*
* This variant is experimental and APIs may change at short notice.
@@ -57,7 +57,7 @@ public class DeferredSXSSFWorkbook extends SXSSFWorkbook {
@NotImplemented
@Override
- protected SheetDataWriter createSheetDataWriter() throws IOException {
+ protected SheetDataWriter createSheetDataWriter() {
throw new IllegalStateException("Not supported by DeferredSXSSFWorkbook");
}
@@ -66,11 +66,9 @@ public class DeferredSXSSFWorkbook extends SXSSFWorkbook {
}
@Override
- protected ISheetInjector createSheetInjector(SXSSFSheet sxSheet) throws IOException {
+ protected ISheetInjector createSheetInjector(SXSSFSheet sxSheet) {
DeferredSXSSFSheet ssxSheet = (DeferredSXSSFSheet) sxSheet;
- return (output) -> {
- ssxSheet.writeRows(output);
- };
+ return ssxSheet::writeRows;
}
@Override
diff --git a/poi/src/test/java/org/apache/poi/ss/formula/TestEvaluationCache.java b/poi/src/test/java/org/apache/poi/ss/formula/TestEvaluationCache.java
index 6af211e7cf..21a318f8b1 100644
--- a/poi/src/test/java/org/apache/poi/ss/formula/TestEvaluationCache.java
+++ b/poi/src/test/java/org/apache/poi/ss/formula/TestEvaluationCache.java
@@ -21,6 +21,7 @@ import static org.junit.jupiter.api.Assertions.assertArrayEquals;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotEquals;
+import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
@@ -669,44 +670,41 @@ class TestEvaluationCache {
}
@Test
- void testPlainValueCache() {
+ void testPlainValueCache() throws IOException {
+ try (Workbook wb = new HSSFWorkbook()) {
+ int numberOfSheets = 4098; // Bug 51448 reported that Evaluation Cache got messed up after 256 sheets
- Workbook wb = new HSSFWorkbook();
- int numberOfSheets = 4098; // Bug 51448 reported that Evaluation Cache got messed up after 256 sheets
+ Row row;
+ Cell cell;
- Row row;
- Cell cell;
+ //create summary sheet
+ Sheet summary = wb.createSheet("summary");
+ wb.setActiveSheet(wb.getSheetIndex(summary));
- //create summary sheet
- Sheet summary = wb.createSheet("summary");
- wb.setActiveSheet(wb.getSheetIndex(summary));
+ //formula referring all sheets created below
+ row = summary.createRow(0);
+ Cell summaryCell = row.createCell(0);
+ summaryCell.setCellFormula("SUM(A2:A" + (numberOfSheets + 2) + ")");
- //formula referring all sheets created below
- row = summary.createRow(0);
- Cell summaryCell = row.createCell(0);
- summaryCell.setCellFormula("SUM(A2:A" + (numberOfSheets + 2) + ")");
+ //create sheets with cells having (different) numbers
+ // and add a row to summary
+ for (int i = 1; i < numberOfSheets; i++) {
+ Sheet sheet = wb.createSheet("new" + i);
+ row = sheet.createRow(0);
+ cell = row.createCell(0);
+ cell.setCellValue(i);
- //create sheets with cells having (different) numbers
- // and add a row to summary
- for (int i = 1; i < numberOfSheets; i++) {
- Sheet sheet = wb.createSheet("new" + i);
+ row = summary.createRow(i);
+ cell = row.createCell(0);
+ cell.setCellFormula("new" + i + "!A1");
- row = sheet.createRow(0);
- cell = row.createCell(0);
- cell.setCellValue(i);
-
- row = summary.createRow(i);
- cell = row.createCell(0);
- cell.setCellFormula("new" + i + "!A1");
+ }
+ //calculate
+ FormulaEvaluator evaluator = wb.getCreationHelper().createFormulaEvaluator();
+ evaluator.evaluateFormulaCell(summaryCell);
+ assertEquals(8394753.0, summaryCell.getNumericCellValue(), 0);
}
-
-
- //calculate
- FormulaEvaluator evaluator = wb.getCreationHelper().createFormulaEvaluator();
- evaluator.evaluateFormulaCell(summaryCell);
- assertEquals(8394753.0, summaryCell.getNumericCellValue(), 0);
}
-
}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@poi.apache.org
For additional commands, e-mail: commits-help@poi.apache.org
(poi) 06/06: Trigger reading metadata-text as part of integration testing
Posted by ce...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
centic pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/poi.git
commit ea74954fcf756ec5714d53aa9b434655ffb30721
Author: Dominik Stadler <do...@gmx.at>
AuthorDate: Sun Oct 5 13:17:30 2025 +0200
Trigger reading metadata-text as part of integration testing
One test-case fails differently now
---
.../org/apache/poi/stress/AbstractFileHandler.java | 5 ++++-
test-data/spreadsheet/stress.xls | Bin 73216 -> 73728 bytes
2 files changed, 4 insertions(+), 1 deletion(-)
diff --git a/poi-integration/src/test/java/org/apache/poi/stress/AbstractFileHandler.java b/poi-integration/src/test/java/org/apache/poi/stress/AbstractFileHandler.java
index c1c96aaa12..c9c6165283 100644
--- a/poi-integration/src/test/java/org/apache/poi/stress/AbstractFileHandler.java
+++ b/poi-integration/src/test/java/org/apache/poi/stress/AbstractFileHandler.java
@@ -192,7 +192,10 @@ public abstract class AbstractFileHandler implements FileHandler {
assertNotNull(streamExtractor.getText());
- assertNotNull(streamExtractor.getMetadataTextExtractor());
+ POITextExtractor metadataTextExtractor = streamExtractor.getMetadataTextExtractor();
+ assertNotNull(metadataTextExtractor);
+
+ assertNotNull(metadataTextExtractor.getText());
}
}
}
diff --git a/test-data/spreadsheet/stress.xls b/test-data/spreadsheet/stress.xls
index ba71dc4ebe..aa42d4cdc8 100644
Binary files a/test-data/spreadsheet/stress.xls and b/test-data/spreadsheet/stress.xls differ
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@poi.apache.org
For additional commands, e-mail: commits-help@poi.apache.org
(poi) 05/06: Add changelog
Posted by ce...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
centic pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/poi.git
commit b5221fac252ea4b39655c0668c4b89bcb86df937
Author: Dominik Stadler <do...@gmx.at>
AuthorDate: Sat Aug 16 09:42:45 2025 +0200
Add changelog
---
src/documentation/content/xdocs/changes.xml | 2 ++
1 file changed, 2 insertions(+)
diff --git a/src/documentation/content/xdocs/changes.xml b/src/documentation/content/xdocs/changes.xml
index e759761bf0..420b8d201c 100644
--- a/src/documentation/content/xdocs/changes.xml
+++ b/src/documentation/content/xdocs/changes.xml
@@ -84,6 +84,7 @@
<summary-item>Upgrade JaCoCo code-coverage tooling to 0.8.13</summary-item>
</summary>
<actions>
+ <action type="fix" fixes-bug="github-879" context="SXSSF">Images in .xlsx-files can lead to temporary files filling up the disk</action>
<action type="fix" fixes-bug="66687" context="SXSSF">Combination of XSSF and SXSSF may result in invalid files</action>
<action type="fix" fixes-bug="69646" context="SXSSF">SXSSF: check for null _fd instance in dispose call</action>
<action type="fix" fixes-bug="69667" context="HSSF">Handle slightly broken WriteAccessRecord gracefully</action>
@@ -107,6 +108,7 @@
<summary-item>Upgrade graphics2d dependency to 3.0.3</summary-item>
</summary>
<actions>
+ <action type="fix" fixes-bug="69563" context="XSSF">Avoid int-overflow when handling file with very many rows and columns</action>
<action type="fix" fixes-bug="69618" context="OOXML">ZipPackage save should check that intermediate steps succeed</action>
<action type="add" fixes-bug="github-775" context="OOXML">Allow some OPC compliance checks to be tuned</action>
<action type="fix" fixes-bug="66260" context="XWPF">Add getNumberOfTexts() method</action>
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@poi.apache.org
For additional commands, e-mail: commits-help@poi.apache.org
(poi) 04/06: Try to verify handling of deeply nested xlsx
Posted by ce...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
centic pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/poi.git
commit 42193c57e41ef2b83a896a54274df7cf4e9331d6
Author: Dominik Stadler <do...@gmx.at>
AuthorDate: Sat Aug 2 13:39:33 2025 +0200
Try to verify handling of deeply nested xlsx
---
.../org/apache/poi/integration/TestXLSX2CSV.java | 21 +++++++++++++++++++++
test-data/spreadsheet/deep-data.xlsx | Bin 0 -> 964835 bytes
test-data/spreadsheet/stress.xls | Bin 73216 -> 73216 bytes
3 files changed, 21 insertions(+)
diff --git a/poi-examples/src/test/java/org/apache/poi/integration/TestXLSX2CSV.java b/poi-examples/src/test/java/org/apache/poi/integration/TestXLSX2CSV.java
index 912890d458..91a64f4601 100644
--- a/poi-examples/src/test/java/org/apache/poi/integration/TestXLSX2CSV.java
+++ b/poi-examples/src/test/java/org/apache/poi/integration/TestXLSX2CSV.java
@@ -18,9 +18,11 @@
package org.apache.poi.integration;
import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.junit.jupiter.api.Assertions.assertTrue;
+import java.io.IOException;
import java.io.PrintStream;
import java.io.UnsupportedEncodingException;
import java.nio.charset.StandardCharsets;
@@ -197,4 +199,23 @@ public class TestXLSX2CSV {
return result.toString();
}
}
+
+ @Test
+ public void testDeepFile() throws Exception {
+ // returns with some System.err
+ try {
+ assertThrows(IOException.class,
+ () -> XLSX2CSV.main(new String[] { XSSFTestDataSamples.getSampleFile("deep-data.xlsx").getAbsolutePath() }));
+ } catch (Throwable e) {
+ // restore output-streams again to get proper error output
+ System.setErr(err);
+
+ throw e;
+ }
+
+ String output = errorBytes.toString(StandardCharsets.UTF_8);
+ assertFalse(output.contains("Not found"), "Had: " + output);
+
+ System.out.println(output);
+ }
}
diff --git a/test-data/spreadsheet/deep-data.xlsx b/test-data/spreadsheet/deep-data.xlsx
new file mode 100644
index 0000000000..cb2a9c84f2
Binary files /dev/null and b/test-data/spreadsheet/deep-data.xlsx differ
diff --git a/test-data/spreadsheet/stress.xls b/test-data/spreadsheet/stress.xls
index f000204abf..ba71dc4ebe 100644
Binary files a/test-data/spreadsheet/stress.xls and b/test-data/spreadsheet/stress.xls differ
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@poi.apache.org
For additional commands, e-mail: commits-help@poi.apache.org
(poi) 01/06: Add a microBenchmark for replacing strings
Posted by ce...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
centic pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/poi.git
commit f10f164c61423158261b49e7db8f01fe92441150
Author: Dominik Stadler <do...@gmx.at>
AuthorDate: Sun Nov 7 07:42:38 2021 +0100
Add a microBenchmark for replacing strings
It shows that Java 11 improves a lot and no custom string-replace
is necessary any more when using this version
---
.../org/apache/poi/integration/TestXLSX2CSV.java | 68 +++++++++++++++++++++-
1 file changed, 66 insertions(+), 2 deletions(-)
diff --git a/poi-examples/src/test/java/org/apache/poi/integration/TestXLSX2CSV.java b/poi-examples/src/test/java/org/apache/poi/integration/TestXLSX2CSV.java
index 0867f12b81..912890d458 100644
--- a/poi-examples/src/test/java/org/apache/poi/integration/TestXLSX2CSV.java
+++ b/poi-examples/src/test/java/org/apache/poi/integration/TestXLSX2CSV.java
@@ -33,8 +33,11 @@ import org.apache.poi.openxml4j.opc.PackageAccess;
import org.apache.poi.xssf.XSSFTestDataSamples;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
+import net.bytebuddy.utility.RandomString;
+
public class TestXLSX2CSV {
private PrintStream err;
private final UnsynchronizedByteArrayOutputStream errorBytes = UnsynchronizedByteArrayOutputStream.builder().get();
@@ -130,7 +133,68 @@ public class TestXLSX2CSV {
assertEquals("", errorOutput);
String output = outputBytes.toString(StandardCharsets.UTF_8);
- assertTrue(output.contains("\"Lorem\",111,,,"), "Had: " + output);
- assertTrue(output.contains(",\"hello, xssf\",,\"hello, xssf\","), "Had: " + output);
+ assertTrue(output.contains("\"Lorem\",111,,,"), "Had: " + output);
+ assertTrue(output.contains(",\"hello, xssf\",,\"hello, xssf\","), "Had: " + output);
}
+
+ @Disabled("Used for local micro-benchmarking")
+ @Test
+ public void microBenchmark() {
+ checkReplace("str");
+ checkReplace("str.123");
+ checkReplace("str.123,");
+ checkReplace("str,,,.123,,,,");
+ for (int i = 0; i < 1000;i++) {
+ checkReplace(RandomString.make(20));
+ }
+
+ for (int i = 0;i < 10;i++) {
+ long start = System.currentTimeMillis();
+ String str = RandomString.make(100) + "\"\"" + RandomString.make(100) + "\"\"" + RandomString.make(100);
+ String expected = str.replace("\"", "\"\"");
+ for (int j = 0;j < 300000;j++) {
+ //assertEquals(expected, replaceString(str, "\"", "\"\""));
+ assertEquals(expected, replaceDirect(str, "\"", "\"\""));
+ }
+
+ System.out.println(" , " + (System.currentTimeMillis() - start));
+ }
+
+ // Java 8: replaceString: 1001, 921, 1264, 1019, 1258, 990, 1089, 1430, 1153, 907
+ // Java 8: replaceDirect: 375, 282, 240, 246, 264, 271, 258, 250, 263, 259
+ // Java 11: replaceString: 510, 218, 202, 205, 202, 198, 202, 198, 208, 201
+ // Java 11: replaceDirect: 384, 228, 204, 201, 201, 200, 206, 196, 200, 200
+ //
+ // => On Java 8, a custom implementation would make sense, however on Java 9
+ // String.replace() was optimized so that it does not make any difference
+ // anymore!
+ }
+
+ private void checkReplace(String orig) {
+ assertEquals(replaceString(orig, ",", "."), replaceDirect(orig, ",", "."),
+ "Did have a difference with " + orig);
+ }
+
+ public static String replaceString(String originalStr, String oldStr, String newStr) {
+ return originalStr.replace(oldStr, newStr);
+ }
+
+ public static String replaceDirect(String originalStr, String oldStr, String newStr) {
+ int p = originalStr.indexOf(oldStr);
+ if (p == -1) {
+ return originalStr;
+ } else {
+ StringBuilder result = new StringBuilder();
+ result.append(originalStr, 0, p);
+ result.append(newStr);
+ int q = p + oldStr.length();
+ while ((p = originalStr.indexOf(oldStr, q)) != -1) {
+ result.append(originalStr, q, p);
+ result.append(newStr);
+ q = p + oldStr.length();
+ }
+ result.append(originalStr, q, originalStr.length());
+ return result.toString();
+ }
+ }
}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@poi.apache.org
For additional commands, e-mail: commits-help@poi.apache.org
(poi) 03/06: TestAllFiles: Add output if a file cannot be matched to a handler
Posted by ce...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
centic pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/poi.git
commit 7003357b7981243175b5f109ebe7a724aa079cdb
Author: Dominik Stadler <do...@gmx.at>
AuthorDate: Sat Aug 2 13:38:38 2025 +0200
TestAllFiles: Add output if a file cannot be matched to a handler
---
.../src/test/java/org/apache/poi/stress/TestAllFiles.java | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/poi-integration/src/test/java/org/apache/poi/stress/TestAllFiles.java b/poi-integration/src/test/java/org/apache/poi/stress/TestAllFiles.java
index 8988c8a180..b73914f09e 100644
--- a/poi-integration/src/test/java/org/apache/poi/stress/TestAllFiles.java
+++ b/poi-integration/src/test/java/org/apache/poi/stress/TestAllFiles.java
@@ -172,6 +172,7 @@ public class TestAllFiles {
continue;
}
+ boolean found = false;
for (FileHandlerKnown handler : sm.getHandler(file)) {
ExcInfo info1 = sm.getExcInfo(file, testName, handler);
if (info1 == null || info1.isValid(testName, handler.name())) {
@@ -182,8 +183,13 @@ public class TestAllFiles {
(info1 != null) ? info1.getExClazz() : null,
(info1 != null) ? info1.getExMessage() : null
));
+ found = true;
}
}
+
+ if (!found) {
+ System.out.println("Could not find a handler for " + file);
+ }
}
return result.stream();
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@poi.apache.org
For additional commands, e-mail: commits-help@poi.apache.org