> head, Boolean convertAllFiled) {
+ super(holder, headClazz, head, convertAllFiled);
}
}
diff --git a/src/main/java/com/alibaba/excel/util/WorkBookUtil.java b/src/main/java/com/alibaba/excel/util/WorkBookUtil.java
index bcec523..186708c 100644
--- a/src/main/java/com/alibaba/excel/util/WorkBookUtil.java
+++ b/src/main/java/com/alibaba/excel/util/WorkBookUtil.java
@@ -31,12 +31,21 @@ public class WorkBookUtil {
if (writeWorkbookHolder.getTempTemplateInputStream() != null) {
XSSFWorkbook xssfWorkbook = new XSSFWorkbook(writeWorkbookHolder.getTempTemplateInputStream());
writeWorkbookHolder.setCachedWorkbook(xssfWorkbook);
- writeWorkbookHolder.setWorkbook(new SXSSFWorkbook(xssfWorkbook, ROW_ACCESS_WINDOW_SIZE));
+ if (writeWorkbookHolder.getInMemory()) {
+ writeWorkbookHolder.setWorkbook(xssfWorkbook);
+ } else {
+ writeWorkbookHolder.setWorkbook(new SXSSFWorkbook(xssfWorkbook, ROW_ACCESS_WINDOW_SIZE));
+ }
return;
}
- SXSSFWorkbook sxssWorkbook = new SXSSFWorkbook(ROW_ACCESS_WINDOW_SIZE);
- writeWorkbookHolder.setCachedWorkbook(sxssWorkbook);
- writeWorkbookHolder.setWorkbook(sxssWorkbook);
+ Workbook workbook = null;
+ if (writeWorkbookHolder.getInMemory()) {
+ workbook = new XSSFWorkbook();
+ } else {
+ workbook = new SXSSFWorkbook(ROW_ACCESS_WINDOW_SIZE);
+ }
+ writeWorkbookHolder.setCachedWorkbook(workbook);
+ writeWorkbookHolder.setWorkbook(workbook);
return;
}
HSSFWorkbook hssfWorkbook;
diff --git a/src/main/java/com/alibaba/excel/write/builder/ExcelWriterBuilder.java b/src/main/java/com/alibaba/excel/write/builder/ExcelWriterBuilder.java
index 82de038..8af1e62 100644
--- a/src/main/java/com/alibaba/excel/write/builder/ExcelWriterBuilder.java
+++ b/src/main/java/com/alibaba/excel/write/builder/ExcelWriterBuilder.java
@@ -4,6 +4,7 @@ import java.io.File;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.ArrayList;
+import java.util.Collection;
import java.util.List;
import com.alibaba.excel.ExcelWriter;
@@ -103,6 +104,48 @@ public class ExcelWriterBuilder {
return this;
}
+ /**
+ * Write excel in memory. Default false,the cache file is created and finally written to excel.
+ *
+ * Comment and RichTextString are only supported in memory mode.
+ */
+ public ExcelWriterBuilder inMemory(Boolean inMemory) {
+ writeWorkbook.setInMemory(inMemory);
+ return this;
+ }
+
+ /**
+ * Ignore the custom columns.
+ */
+ public ExcelWriterBuilder excludeColumnIndexes(Collection excludeColumnIndexes) {
+ writeWorkbook.setExcludeColumnIndexes(excludeColumnIndexes);
+ return this;
+ }
+
+ /**
+ * Ignore the custom columns.
+ */
+ public ExcelWriterBuilder excludeColumnFiledNames(Collection excludeColumnFiledNames) {
+ writeWorkbook.setExcludeColumnFiledNames(excludeColumnFiledNames);
+ return this;
+ }
+
+ /**
+ * Only output the custom columns.
+ */
+ public ExcelWriterBuilder includeColumnIndexes(Collection includeColumnIndexes) {
+ writeWorkbook.setIncludeColumnIndexes(includeColumnIndexes);
+ return this;
+ }
+
+ /**
+ * Only output the custom columns.
+ */
+ public ExcelWriterBuilder includeColumnFiledNames(Collection includeColumnFiledNames) {
+ writeWorkbook.setIncludeColumnFiledNames(includeColumnFiledNames);
+ return this;
+ }
+
/**
* The default is all excel objects.if true , you can use {@link com.alibaba.excel.annotation.ExcelIgnore} ignore a
* field. if false , you must use {@link com.alibaba.excel.annotation.ExcelProperty} to use a filed.
diff --git a/src/main/java/com/alibaba/excel/write/builder/ExcelWriterSheetBuilder.java b/src/main/java/com/alibaba/excel/write/builder/ExcelWriterSheetBuilder.java
index 26acff5..50f230a 100644
--- a/src/main/java/com/alibaba/excel/write/builder/ExcelWriterSheetBuilder.java
+++ b/src/main/java/com/alibaba/excel/write/builder/ExcelWriterSheetBuilder.java
@@ -1,6 +1,7 @@
package com.alibaba.excel.write.builder;
import java.util.ArrayList;
+import java.util.Collection;
import java.util.List;
import com.alibaba.excel.ExcelWriter;
@@ -135,6 +136,38 @@ public class ExcelWriterSheetBuilder {
return this;
}
+ /**
+ * Ignore the custom columns.
+ */
+ public ExcelWriterSheetBuilder excludeColumnIndexes(Collection excludeColumnIndexes) {
+ writeSheet.setExcludeColumnIndexes(excludeColumnIndexes);
+ return this;
+ }
+
+ /**
+ * Ignore the custom columns.
+ */
+ public ExcelWriterSheetBuilder excludeColumnFiledNames(Collection excludeColumnFiledNames) {
+ writeSheet.setExcludeColumnFiledNames(excludeColumnFiledNames);
+ return this;
+ }
+
+ /**
+ * Only output the custom columns.
+ */
+ public ExcelWriterSheetBuilder includeColumnIndexes(Collection includeColumnIndexes) {
+ writeSheet.setIncludeColumnIndexes(includeColumnIndexes);
+ return this;
+ }
+
+ /**
+ * Only output the custom columns.
+ */
+ public ExcelWriterSheetBuilder includeColumnFiledNames(Collection includeColumnFiledNames) {
+ writeSheet.setIncludeColumnFiledNames(includeColumnFiledNames);
+ return this;
+ }
+
public WriteSheet build() {
return writeSheet;
}
diff --git a/src/main/java/com/alibaba/excel/write/builder/ExcelWriterTableBuilder.java b/src/main/java/com/alibaba/excel/write/builder/ExcelWriterTableBuilder.java
index eca1fe0..40ca58b 100644
--- a/src/main/java/com/alibaba/excel/write/builder/ExcelWriterTableBuilder.java
+++ b/src/main/java/com/alibaba/excel/write/builder/ExcelWriterTableBuilder.java
@@ -1,6 +1,7 @@
package com.alibaba.excel.write.builder;
import java.util.ArrayList;
+import java.util.Collection;
import java.util.List;
import com.alibaba.excel.ExcelWriter;
@@ -128,6 +129,39 @@ public class ExcelWriterTableBuilder {
return this;
}
+
+ /**
+ * Ignore the custom columns.
+ */
+ public ExcelWriterTableBuilder excludeColumnIndexes(Collection excludeColumnIndexes) {
+ writeTable.setExcludeColumnIndexes(excludeColumnIndexes);
+ return this;
+ }
+
+ /**
+ * Ignore the custom columns.
+ */
+ public ExcelWriterTableBuilder excludeColumnFiledNames(Collection excludeColumnFiledNames) {
+ writeTable.setExcludeColumnFiledNames(excludeColumnFiledNames);
+ return this;
+ }
+
+ /**
+ * Only output the custom columns.
+ */
+ public ExcelWriterTableBuilder includeColumnIndexes(Collection includeColumnIndexes) {
+ writeTable.setIncludeColumnIndexes(includeColumnIndexes);
+ return this;
+ }
+
+ /**
+ * Only output the custom columns.
+ */
+ public ExcelWriterTableBuilder includeColumnFiledNames(Collection includeColumnFiledNames) {
+ writeSheet.setIncludeColumnFiledNames(includeColumnFiledNames);
+ return this;
+ }
+
public WriteTable build() {
return writeTable;
}
diff --git a/src/main/java/com/alibaba/excel/write/executor/ExcelWriteAddExecutor.java b/src/main/java/com/alibaba/excel/write/executor/ExcelWriteAddExecutor.java
index 8843e2c..0fa0cae 100644
--- a/src/main/java/com/alibaba/excel/write/executor/ExcelWriteAddExecutor.java
+++ b/src/main/java/com/alibaba/excel/write/executor/ExcelWriteAddExecutor.java
@@ -98,6 +98,9 @@ public class ExcelWriteAddExecutor extends AbstractExcelWriteExecutor {
private void doAddBasicTypeToExcel(List