This is an automated email from the ASF dual-hosted git repository.
ahuber pushed a commit to branch v4
in repository https://gitbox.apache.org/repos/asf/causeway.git
The following commit(s) were added to refs/heads/v4 by this push:
new ee6ee05a252 CAUSEWAY-3901: for large XLSX exports, disable cell
row/col autosizing
ee6ee05a252 is described below
commit ee6ee05a252f522450859ec86862aae49529e040
Author: Andi Huber <[email protected]>
AuthorDate: Thu Aug 28 19:04:35 2025 +0200
CAUSEWAY-3901: for large XLSX exports, disable cell row/col autosizing
---
.../causeway/commons/tabular/TabularModel.java | 7 +++----
.../tabular/excel/exporter/ExcelFileWriter.java | 23 +++++++++++++++++-----
2 files changed, 21 insertions(+), 9 deletions(-)
diff --git
a/commons/src/main/java/org/apache/causeway/commons/tabular/TabularModel.java
b/commons/src/main/java/org/apache/causeway/commons/tabular/TabularModel.java
index 5f7fa14c603..ea383d5fe88 100644
---
a/commons/src/main/java/org/apache/causeway/commons/tabular/TabularModel.java
+++
b/commons/src/main/java/org/apache/causeway/commons/tabular/TabularModel.java
@@ -22,7 +22,6 @@
import java.util.function.Supplier;
import java.util.stream.Stream;
-import org.springframework.lang.NonNull;
import org.jspecify.annotations.Nullable;
import org.apache.causeway.commons.collections.Can;
@@ -72,7 +71,7 @@ public record TabularCell(
* E.g. a TabularCell can decide to provide a label instead of a
pojo,
* even though cardinality is 1.
*/
- @NonNull Either<Object, Supplier<Stream<String>>>
eitherValueOrLabelSupplier) {
+ Either<Object, Supplier<Stream<String>>>
eitherValueOrLabelSupplier) {
// -- FACTORIES
@@ -84,7 +83,7 @@ public static TabularCell single(final @Nullable Object
value) {
? EMPTY
: new TabularCell(1, Either.left(value));
}
- public static TabularCell labeled(final int cardinality, final
@NonNull Supplier<Stream<String>> labelSupplier) {
+ public static TabularCell labeled(final int cardinality, final
Supplier<Stream<String>> labelSupplier) {
Objects.requireNonNull(labelSupplier);
return new TabularCell(cardinality, Either.right(labelSupplier));
}
@@ -93,7 +92,7 @@ public static TabularCell labeled(final int cardinality,
final @NonNull Supplier
public TabularCell(
final int cardinality,
- final @NonNull Either<Object, Supplier<Stream<String>>>
eitherValueOrLabelSupplier) {
+ final Either<Object, Supplier<Stream<String>>>
eitherValueOrLabelSupplier) {
Objects.requireNonNull(eitherValueOrLabelSupplier);
if(cardinality<0) throw _Exceptions.illegalArgument("cardinality
cannot be negative: %d", cardinality);
if(cardinality==0) {
diff --git
a/extensions/vw/tabular/excel/src/main/java/org/apache/causeway/extensions/tabular/excel/exporter/ExcelFileWriter.java
b/extensions/vw/tabular/excel/src/main/java/org/apache/causeway/extensions/tabular/excel/exporter/ExcelFileWriter.java
index cba584659bc..88f493c0ce9 100644
---
a/extensions/vw/tabular/excel/src/main/java/org/apache/causeway/extensions/tabular/excel/exporter/ExcelFileWriter.java
+++
b/extensions/vw/tabular/excel/src/main/java/org/apache/causeway/extensions/tabular/excel/exporter/ExcelFileWriter.java
@@ -45,10 +45,12 @@
import lombok.Builder;
import lombok.RequiredArgsConstructor;
import lombok.SneakyThrows;
+import lombok.extern.slf4j.Slf4j;
/**
* Utility to write a {@link TabularModel} to file.
*/
+@Slf4j
public record ExcelFileWriter(@Nullable Options options) {
@Builder
@@ -122,13 +124,13 @@ private void writeSheet(final Workbook wb, final
TabularModel.TabularSheet tabul
var sheetName = tabularSheet.sheetName();
Row row;
-
+
var sheet = wb.createSheet(sheetName);
if(sheet instanceof SXSSFSheet sxssfSheet) {
sxssfSheet.trackAllColumnsForAutoSizing();
}
var cellWriter = new ExcelCellWriter(5, new ExcelImageHandler(sheet));
-
+
var cellStyleProvider = CellStyleProvider.create(wb, options);
var rowFactory = new RowFactory(sheet);
@@ -160,6 +162,9 @@ private void writeSheet(final Workbook wb, final
TabularModel.TabularSheet tabul
var dataRows = tabularSheet.rows();
+ var isLarge = dataRows.size()>=10000;
+ int writtenCount = 0;
+
// detail rows
for (var dataRow : dataRows) {
row = rowFactory.newRow();
@@ -176,11 +181,19 @@ private void writeSheet(final Workbook wb, final
TabularModel.TabularSheet tabul
maxLinesInRow.accept(linesWritten);
}
cellStyleProvider.applyCustomStyle(dataRow, row);
- autoSizeRow(row, maxLinesInRow.getResult().orElse(1), null);
+ ++writtenCount;
+
+ if(!isLarge) {
+ autoSizeRow(row, maxLinesInRow.getResult().orElse(1), null);
+ } else if(writtenCount%1000==0) {
+ log.info("rows written %dk of %dk%n", writtenCount/1000,
(dataRows.size()+500)/1000);
+ }
}
- // column auto-size
- autoSizeColumns(sheet, dataColumns.size());
+ if(!isLarge) {
+ // column auto-size
+ autoSizeColumns(sheet, dataColumns.size());
+ }
// freeze panes
sheet.createFreezePane(0, 2);