public class WorkBookUtil {
private WorkBookUtil() {}
public static void createWorkBook(WriteWorkbookHolder writeWorkbookHolder) throws IOException {
switch (writeWorkbookHolder.getExcelType()) {
case XLSX:
if (writeWorkbookHolder.getTempTemplateInputStream() != null) {
XSSFWorkbook xssfWorkbook = new XSSFWorkbook(writeWorkbookHolder.getTempTemplateInputStream());
writeWorkbookHolder.setCachedWorkbook(xssfWorkbook);
if (writeWorkbookHolder.getInMemory()) {
writeWorkbookHolder.setWorkbook(xssfWorkbook);
} else {
writeWorkbookHolder.setWorkbook(new SXSSFWorkbook(xssfWorkbook));
}
return;
}
Workbook workbook;
if (writeWorkbookHolder.getInMemory()) {
workbook = new XSSFWorkbook();
} else {
workbook = new SXSSFWorkbook();
}
writeWorkbookHolder.setCachedWorkbook(workbook);
writeWorkbookHolder.setWorkbook(workbook);
return;
public class SXSSFWorkbook implements Workbook {
/**
* Specifies how many rows can be accessed at most via {@link SXSSFSheet#getRow}.
* When a new node is created via {@link SXSSFSheet#createRow} and the total number
* of unflushed records would exceed the specified value, then the
* row with the lowest index value is flushed and cannot be accessed
* via {@link SXSSFSheet#getRow} anymore.
*/
public static final int DEFAULT_WINDOW_SIZE = 100;
public class WorkBookUtil {
private WorkBookUtil() {}
public static void createWorkBook(WriteWorkbookHolder writeWorkbookHolder) throws IOException {
switch (writeWorkbookHolder.getExcelType()) {
case XLSX:
if (writeWorkbookHolder.getTempTemplateInputStream() != null) {
XSSFWorkbook xssfWorkbook = new XSSFWorkbook(writeWorkbookHolder.getTempTemplateInputStream());
writeWorkbookHolder.setCachedWorkbook(xssfWorkbook);
if (writeWorkbookHolder.getInMemory()) {
writeWorkbookHolder.setWorkbook(xssfWorkbook);
} else {
writeWorkbookHolder.setWorkbook(new SXSSFWorkbook(xssfWorkbook));
}
return;
}
Workbook workbook;
if (writeWorkbookHolder.getInMemory()) {
workbook = new XSSFWorkbook();
} else {
workbook = new SXSSFWorkbook();
}
writeWorkbookHolder.setCachedWorkbook(workbook);
writeWorkbookHolder.setWorkbook(workbook);
return;
public class SXSSFWorkbook implements Workbook {
/**
* Specifies how many rows can be accessed at most via {@link SXSSFSheet#getRow}.
* When a new node is created via {@link SXSSFSheet#createRow} and the total number
* of unflushed records would exceed the specified value, then the
* row with the lowest index value is flushed and cannot be accessed
* via {@link SXSSFSheet#getRow} anymore.
*/
public static final int DEFAULT_WINDOW_SIZE = 100;
5条答案
按热度按时间wnrlj8wa1#
easyExcel 默认使用的是SXSSFWorkbook ,SXSSFWorkbook 会在数据行超出范围后刷新到文件中去。注意不要使用内存模式及文件类型是xlsx,图片类型是不支持的。写入数据后及时释放避免内存泄漏
iklwldmw2#
easyExcel 默认使用的是SXSSFWorkbook ,SXSSFWorkbook 会在数据行超出范围后刷新到文件中去。注意不要使用内存模式及文件类型是xlsx,图片类型是不支持的。写入数据后及时释放避免内存泄漏
图片类型不支持,意思是如果导出的excel包含图片的话?那么必须将图片全部加载到内存吗?那我导出1-2g的文件,是不是需要非常大的堆内存才行呢?大佬求解
hrysbysz3#
你好,我们发现此Issue已经超过三个月没有活动了,为了更好的帮助您解决问题,我们将在两周后关闭此Issue,如果您仍然有问题,请在两周内内回复此Issue,谢谢!如果您已经解决或者不需要帮助,请忽略此消息。
g52tjvyc4#
你好,我们发现此Issue已经超过三个月没有活动了,为了更好的帮助您解决问题,我们将在两周后关闭此Issue,如果您仍然有问题,请在两周内内回复此Issue,谢谢!如果您已经解决或者不需要帮助,请忽略此消息。
你好,我在尝试多次写入时报错说sheet已存在,请您看一下.
ev7lccsx5#
你好,我们发现此Issue已经超过三个月没有活动了,为了更好的帮助您解决问题,我们将在两周后关闭此Issue,如果您仍然有问题,请在两周内内回复此Issue,谢谢!如果您已经解决或者不需要帮助,请忽略此消息。