public class BigExcelWriter extends ExcelWriter
SXSSFWorkbook
,限制对滑动窗口中的行的访问来实现其低内存使用。Modifier and Type | Field and Description |
---|---|
static int |
DEFAULT_WINDOW_SIZE |
Constructor and Description |
---|
BigExcelWriter()
构造,默认生成xlsx格式的Excel文件
此构造不传入写出的Excel文件路径,只能调用 ExcelWriter.flush(java.io.OutputStream) 方法写出到流若写出到文件,还需调用 ExcelWriter.setDestFile(File) 方法自定义写出的文件,然后调用ExcelWriter.flush() 方法写出到文件 |
BigExcelWriter(File destFile)
构造,默认写出到第一个sheet,第一个sheet名为sheet1
|
BigExcelWriter(File destFile,
String sheetName)
构造
|
BigExcelWriter(int rowAccessWindowSize)
构造
此构造不传入写出的Excel文件路径,只能调用 ExcelWriter.flush(java.io.OutputStream) 方法写出到流若写出到文件,需要调用 ExcelWriter.flush(File) 写出到文件 |
BigExcelWriter(int rowAccessWindowSize,
boolean compressTmpFiles,
boolean useSharedStringsTable,
String sheetName)
构造
此构造不传入写出的Excel文件路径,只能调用 ExcelWriter.flush(java.io.OutputStream) 方法写出到流若写出到文件,需要调用 ExcelWriter.flush(File) 写出到文件 |
BigExcelWriter(int rowAccessWindowSize,
String sheetName)
构造
此构造不传入写出的Excel文件路径,只能调用 ExcelWriter.flush(java.io.OutputStream) 方法写出到流若写出到文件,需要调用 ExcelWriter.flush(File) 写出到文件 |
BigExcelWriter(org.apache.poi.ss.usermodel.Sheet sheet)
构造
此构造不传入写出的Excel文件路径,只能调用 ExcelWriter.flush(java.io.OutputStream) 方法写出到流若写出到文件,还需调用 ExcelWriter.setDestFile(File) 方法自定义写出的文件,然后调用ExcelWriter.flush() 方法写出到文件 |
BigExcelWriter(String destFilePath)
构造,默认写出到第一个sheet,第一个sheet名为sheet1
|
BigExcelWriter(String destFilePath,
String sheetName)
构造
|
BigExcelWriter(org.apache.poi.xssf.streaming.SXSSFWorkbook workbook,
String sheetName)
构造
此构造不传入写出的Excel文件路径,只能调用 ExcelWriter.flush(java.io.OutputStream) 方法写出到流若写出到文件,还需调用 ExcelWriter.setDestFile(File) 方法自定义写出的文件,然后调用ExcelWriter.flush() 方法写出到文件 |
Modifier and Type | Method and Description |
---|---|
BigExcelWriter |
autoSizeColumn(int columnIndex)
设置某列为自动宽度,不考虑合并单元格
此方法必须在指定列数据完全写出后调用才有效。 |
BigExcelWriter |
autoSizeColumnAll()
设置所有列为自动宽度,不考虑合并单元格
此方法必须在指定列数据完全写出后调用才有效。 |
BigExcelWriter |
autoSizeColumnAll(float widthRatio)
设置所有列为自动宽度,不考虑合并单元格
此方法必须在指定列数据完全写出后调用才有效。 |
void |
close()
关闭工作簿
如果用户设定了目标文件,先写出目标文件后给关闭工作簿 |
ExcelWriter |
flush(OutputStream out,
boolean isCloseOut)
将Excel Workbook刷出到输出流
|
addHeaderAlias, addIgnoredErrors, addSelect, addSelect, addValidationData, autoSizeColumn, autoSizeColumn, autoSizeColumn, clearHeaderAlias, closeWithoutFlush, createFont, disableDefaultStyle, flush, flush, flush, getCellStyle, getContentType, getCurrentRow, getDisposition, getHeadCellStyle, getStyleSet, merge, merge, merge, merge, merge, passCurrentRow, passRows, renameSheet, renameSheet, reset, resetRow, setColumnStyle, setColumnStyleIfHasData, setColumnWidth, setCurrentRow, setCurrentRowToEnd, setDefaultRowHeight, setDestFile, setFreezePane, setFreezePane, setHeaderAlias, setHeaderOrFooter, setOnlyAlias, setRowHeight, setRowStyle, setRowStyleIfHasData, setSheet, setSheet, setStyle, setStyle, setStyleSet, write, write, write, writeCellValue, writeCellValue, writeCellValue, writeCellValue, writeCol, writeCol, writeCol, writeCol, writeHeadRow, writeImg, writeImg, writeImg, writeImg, writeRow, writeRow, writeRow, writeSecHeadRow
cloneSheet, createCellStyle, createCellStyle, createCellStyle, createColumnStyle, createHyperlink, createHyperlink, createRowStyle, getCell, getCell, getCell, getCell, getColumnCount, getColumnCount, getHeaderAlias, getOrCreateCell, getOrCreateCell, getOrCreateCellStyle, getOrCreateCellStyle, getOrCreateColumnStyle, getOrCreateRow, getOrCreateRowStyle, getPhysicalRowCount, getRowCount, getSheet, getSheetCount, getSheetNames, getSheets, getWorkbook, isXlsx, removeHeaderAlias, setSheet
public static final int DEFAULT_WINDOW_SIZE
public BigExcelWriter()
ExcelWriter.flush(java.io.OutputStream)
方法写出到流ExcelWriter.setDestFile(File)
方法自定义写出的文件,然后调用ExcelWriter.flush()
方法写出到文件public BigExcelWriter(int rowAccessWindowSize)
ExcelWriter.flush(java.io.OutputStream)
方法写出到流ExcelWriter.flush(File)
写出到文件rowAccessWindowSize
- 在内存中的行数public BigExcelWriter(int rowAccessWindowSize, boolean compressTmpFiles, boolean useSharedStringsTable, String sheetName)
ExcelWriter.flush(java.io.OutputStream)
方法写出到流ExcelWriter.flush(File)
写出到文件rowAccessWindowSize
- 在内存中的行数,-1表示不限制,此时需要手动刷出compressTmpFiles
- 是否使用Gzip压缩临时文件useSharedStringsTable
- 是否使用共享字符串表,一般大量重复字符串时开启可节省内存sheetName
- 写出的sheet名称public BigExcelWriter(String destFilePath)
destFilePath
- 目标文件路径,可以不存在public BigExcelWriter(int rowAccessWindowSize, String sheetName)
ExcelWriter.flush(java.io.OutputStream)
方法写出到流ExcelWriter.flush(File)
写出到文件rowAccessWindowSize
- 在内存中的行数sheetName
- sheet名,第一个sheet名并写出到此sheet,例如sheet1public BigExcelWriter(String destFilePath, String sheetName)
destFilePath
- 目标文件路径,可以不存在sheetName
- sheet名,第一个sheet名并写出到此sheet,例如sheet1public BigExcelWriter(File destFile)
destFile
- 目标文件,可以不存在public BigExcelWriter(File destFile, String sheetName)
destFile
- 目标文件,可以不存在sheetName
- sheet名,做为第一个sheet名并写出到此sheet,例如sheet1public BigExcelWriter(org.apache.poi.xssf.streaming.SXSSFWorkbook workbook, String sheetName)
ExcelWriter.flush(java.io.OutputStream)
方法写出到流ExcelWriter.setDestFile(File)
方法自定义写出的文件,然后调用ExcelWriter.flush()
方法写出到文件workbook
- SXSSFWorkbook
sheetName
- sheet名,做为第一个sheet名并写出到此sheet,例如sheet1public BigExcelWriter(org.apache.poi.ss.usermodel.Sheet sheet)
ExcelWriter.flush(java.io.OutputStream)
方法写出到流ExcelWriter.setDestFile(File)
方法自定义写出的文件,然后调用ExcelWriter.flush()
方法写出到文件sheet
- Sheet
public BigExcelWriter autoSizeColumn(int columnIndex)
ExcelWriter
autoSizeColumn
in class ExcelWriter
columnIndex
- 第几列,从0计数public BigExcelWriter autoSizeColumnAll()
ExcelWriter
autoSizeColumnAll
in class ExcelWriter
public BigExcelWriter autoSizeColumnAll(float widthRatio)
ExcelWriter
autoSizeColumnAll
in class ExcelWriter
widthRatio
- 列宽的倍数。如果所有内容都是英文,可以设为1,如果有中文,建议设置为 1.6-2.0之间。public ExcelWriter flush(OutputStream out, boolean isCloseOut) throws IORuntimeException
ExcelWriter
flush
in class ExcelWriter
out
- 输出流isCloseOut
- 是否关闭输出流IORuntimeException
- IO异常public void close()
ExcelWriter
close
in interface Closeable
close
in interface AutoCloseable
close
in class ExcelWriter
Copyright © 2024. All rights reserved.