public abstract class BaseExcelWriter<K,V> extends Object
不支持复杂类型 (图片 超链接 注释)
Modifier and Type | Field and Description |
---|---|
protected int |
columnMaxIndex
最大列索引
|
protected Map<Integer,org.apache.poi.ss.usermodel.CellStyle> |
columnStyles
数据样式
|
protected Map<Integer,Function<V,Selector<V,org.apache.poi.ss.usermodel.CellStyle>>> |
columnStyleSelector
数据样式选择器
有选择到的将会覆盖原有样式
|
protected boolean |
columnUseDefaultStyle
列是否使用默认样式 全局
skip() 会使用默认样式
|
protected int |
headerHeight
表头行高
|
protected Map<Integer,org.apache.poi.ss.usermodel.CellStyle> |
headerStyles
表头样式
|
protected boolean |
headerUseRowStyle
是否使用头部样式
|
protected Map<K,WriteFieldOption> |
options
配置项
|
protected int |
rowHeight
行高
|
protected int |
rowIndex
当前行索引
|
protected org.apache.poi.ss.usermodel.Sheet |
sheet |
protected boolean |
skipNullRows
是否跳过null
|
protected int |
titleHeight
标题行高
|
protected org.apache.poi.ss.usermodel.CellStyle |
titleStyle
标题样式
|
protected boolean |
trim
是否清除空格
|
protected org.apache.poi.ss.usermodel.Workbook |
workbook |
Constructor and Description |
---|
BaseExcelWriter(org.apache.poi.ss.usermodel.Workbook workbook,
org.apache.poi.ss.usermodel.Sheet sheet) |
Modifier and Type | Method and Description |
---|---|
protected void |
addOption(K k,
WriteFieldOption option,
Object defaultValue)
添加列配置
|
BaseExcelWriter<K,V> |
addRow(V row)
添加行
|
BaseExcelWriter<K,V> |
addRows(Collection<V> list)
添加行
|
BaseExcelWriter<K,V> |
columnUseDefaultStyle()
列是否使用默认样式 需要在设置样式之前调用
|
org.apache.poi.ss.usermodel.CellStyle |
createCellStyle()
获取一个单元格样式 用于样式修改
|
org.apache.poi.ss.usermodel.Font |
createFont()
获取一个字体 用于样式修改
|
org.apache.poi.ss.usermodel.DataFormat |
createFormat()
获取一个格式 用于样式修改
|
BaseExcelWriter<K,V> |
defaultValue(K k,
Object value)
设置默认值
|
BaseExcelWriter<K,V> |
displayFormulas()
不执行公式 会修改列宽单位
|
BaseExcelWriter<K,V> |
displayGridLines()
不显示网格线
|
BaseExcelWriter<K,V> |
displayRowColHeadings()
不显示行数和列数
|
BaseExcelWriter<K,V> |
filter()
筛选列
|
BaseExcelWriter<K,V> |
filter(int rowIndex)
筛选列
|
BaseExcelWriter<K,V> |
filter(int rowIndex,
int lastColumn)
筛选列
|
BaseExcelWriter<K,V> |
footer(FooterOption option)
设置页脚
|
BaseExcelWriter<K,V> |
freeze()
固定行
|
BaseExcelWriter<K,V> |
freeze(int row)
固定行
|
int |
getColumnMaxIndex()
获取最大列索引
|
int |
getLines()
获取总行数
|
int |
getRowIndex() |
org.apache.poi.ss.usermodel.Sheet |
getSheet() |
protected abstract Object |
getValue(V row,
K key)
获取值
|
org.apache.poi.ss.usermodel.Workbook |
getWorkbook() |
BaseExcelWriter<K,V> |
header(HeaderOption option)
设置页眉
|
BaseExcelWriter<K,V> |
headerHeight(int height)
设置表头默认行高
|
BaseExcelWriter<K,V> |
headers(String... headers)
添加表头
|
BaseExcelWriter<K,V> |
headerStyle(int column,
org.apache.poi.ss.usermodel.CellStyle style)
设置头 style
|
BaseExcelWriter<K,V> |
headerUseRowStyle()
表头是否使用行样式
|
BaseExcelWriter<K,V> |
height(int height)
设置默认行高
|
BaseExcelWriter<K,V> |
hidden()
设置隐藏表格
|
BaseExcelWriter<K,V> |
hidden(int column)
设置隐藏列
|
BaseExcelWriter<K,V> |
merge(org.apache.poi.ss.util.CellRangeAddress region,
boolean mergeBorder)
合并单元格
|
BaseExcelWriter<K,V> |
merge(int row,
int firstCol,
int lastCol) |
BaseExcelWriter<K,V> |
merge(int row,
int firstCol,
int lastCol,
boolean mergeBorder) |
BaseExcelWriter<K,V> |
merge(int firstRow,
int lastRow,
int firstCol,
int lastCol) |
BaseExcelWriter<K,V> |
merge(int firstRow,
int lastRow,
int firstCol,
int lastCol,
boolean mergeBorder)
合并单元格
|
BaseExcelWriter<K,V> |
option(int column,
K k) |
BaseExcelWriter<K,V> |
option(int column,
K k,
ExcelFieldType type) |
BaseExcelWriter<K,V> |
option(int column,
K k,
ExcelFieldType type,
Object defaultValue) |
BaseExcelWriter<K,V> |
option(int column,
K k,
ExcelFieldType type,
String format) |
BaseExcelWriter<K,V> |
option(int column,
K k,
ExcelFieldType type,
String format,
Object defaultValue)
添加列配置
|
BaseExcelWriter<K,V> |
option(int column,
K k,
Object defaultValue) |
BaseExcelWriter<K,V> |
option(K k,
WriteFieldOption option) |
BaseExcelWriter<K,V> |
option(K k,
WriteFieldOption option,
Object defaultValue)
添加列配置
|
BaseExcelWriter<K,V> |
print(PrintOption option)
设置打印属性
|
BaseExcelWriter<K,V> |
protect(String password)
保护表格
|
BaseExcelWriter<K,V> |
rowHeight(int height)
设数据行高
|
BaseExcelWriter<K,V> |
selected()
设置选中
|
BaseExcelWriter<K,V> |
skip()
跳过一行
|
BaseExcelWriter<K,V> |
skip(int i)
跳过多行
|
BaseExcelWriter<K,V> |
skipNullRows(boolean skip)
跳过空行
|
BaseExcelWriter<K,V> |
style(int column,
org.apache.poi.ss.usermodel.CellStyle style)
设置列 style
|
BaseExcelWriter<K,V> |
style(int column,
Function<V,Selector<V,org.apache.poi.ss.usermodel.CellStyle>> selector)
设置列样式选择器
|
BaseExcelWriter<K,V> |
title(String title)
添加标题
|
BaseExcelWriter<K,V> |
title(String title,
int row)
添加标题
|
BaseExcelWriter<K,V> |
title(String title,
int row,
int lastColumnIndex)
添加标题
|
BaseExcelWriter<K,V> |
titleHeight(int height)
设置标题行高
|
BaseExcelWriter<K,V> |
titleStyle(org.apache.poi.ss.usermodel.CellStyle style)
设置标题 style
|
BaseExcelWriter<K,V> |
trim()
跳过首尾空格
|
BaseExcelWriter<K,V> |
width(int width)
设置默认行宽
|
BaseExcelWriter<K,V> |
width(int column,
int width)
设置行宽
|
protected org.apache.poi.ss.usermodel.Workbook workbook
protected org.apache.poi.ss.usermodel.Sheet sheet
protected int rowIndex
protected int columnMaxIndex
protected boolean skipNullRows
protected boolean trim
String
protected boolean columnUseDefaultStyle
protected boolean headerUseRowStyle
protected int titleHeight
protected int headerHeight
protected int rowHeight
protected Map<K,WriteFieldOption> options
protected org.apache.poi.ss.usermodel.CellStyle titleStyle
public BaseExcelWriter(org.apache.poi.ss.usermodel.Workbook workbook, org.apache.poi.ss.usermodel.Sheet sheet)
public BaseExcelWriter<K,V> title(String title)
title
- titlepublic BaseExcelWriter<K,V> title(String title, int row)
title
- titlerow
- 使用行数public BaseExcelWriter<K,V> title(String title, int row, int lastColumnIndex)
title
- titlerow
- 使用行数lastColumnIndex
- 列数索引public BaseExcelWriter<K,V> headers(String... headers)
headers
- 表头public BaseExcelWriter<K,V> skip()
public BaseExcelWriter<K,V> skip(int i)
i
- 行public BaseExcelWriter<K,V> skipNullRows(boolean skip)
skip
- 跳过空行public BaseExcelWriter<K,V> trim()
public BaseExcelWriter<K,V> width(int column, int width)
column
- 列索引width
- 行宽public BaseExcelWriter<K,V> width(int width)
width
- 行宽public BaseExcelWriter<K,V> height(int height)
height
- 行高public BaseExcelWriter<K,V> rowHeight(int height)
height
- 行高public BaseExcelWriter<K,V> titleHeight(int height)
height
- 行高public BaseExcelWriter<K,V> headerHeight(int height)
height
- 行高public BaseExcelWriter<K,V> columnUseDefaultStyle()
public BaseExcelWriter<K,V> headerUseRowStyle()
public BaseExcelWriter<K,V> style(int column, org.apache.poi.ss.usermodel.CellStyle style)
column
- 列style
- stylepublic BaseExcelWriter<K,V> style(int column, Function<V,Selector<V,org.apache.poi.ss.usermodel.CellStyle>> selector)
column
- columnselector
- selectorpublic BaseExcelWriter<K,V> headerStyle(int column, org.apache.poi.ss.usermodel.CellStyle style)
column
- 列style
- stylepublic BaseExcelWriter<K,V> titleStyle(org.apache.poi.ss.usermodel.CellStyle style)
style
- stylepublic BaseExcelWriter<K,V> selected()
public BaseExcelWriter<K,V> hidden()
public BaseExcelWriter<K,V> hidden(int column)
column
- 列public BaseExcelWriter<K,V> filter()
public BaseExcelWriter<K,V> filter(int rowIndex)
rowIndex
- rowIndexpublic BaseExcelWriter<K,V> filter(int rowIndex, int lastColumn)
rowIndex
- rowIndexlastColumn
- lastColumnpublic BaseExcelWriter<K,V> freeze()
public BaseExcelWriter<K,V> freeze(int row)
row
- rowpublic BaseExcelWriter<K,V> option(int column, K k)
public BaseExcelWriter<K,V> option(int column, K k, Object defaultValue)
public BaseExcelWriter<K,V> option(int column, K k, ExcelFieldType type)
public BaseExcelWriter<K,V> option(int column, K k, ExcelFieldType type, Object defaultValue)
public BaseExcelWriter<K,V> option(int column, K k, ExcelFieldType type, String format)
public BaseExcelWriter<K,V> option(int column, K k, ExcelFieldType type, String format, Object defaultValue)
k
- kcolumn
- columntype
- typeformat
- formatdefaultValue
- defaultValuepublic BaseExcelWriter<K,V> option(K k, WriteFieldOption option)
public BaseExcelWriter<K,V> option(K k, WriteFieldOption option, Object defaultValue)
k
- koption
- optiondefaultValue
- defaultValueprotected void addOption(K k, WriteFieldOption option, Object defaultValue)
k
- koption
- optionpublic BaseExcelWriter<K,V> defaultValue(K k, Object value)
k
- Kvalue
- 默认值public BaseExcelWriter<K,V> merge(int row, int firstCol, int lastCol)
public BaseExcelWriter<K,V> merge(int row, int firstCol, int lastCol, boolean mergeBorder)
public BaseExcelWriter<K,V> merge(int firstRow, int lastRow, int firstCol, int lastCol)
public BaseExcelWriter<K,V> merge(int firstRow, int lastRow, int firstCol, int lastCol, boolean mergeBorder)
firstRow
- 合并开始行索引lastRow
- 合并结束行索引firstCol
- 合并开始列索引lastCol
- 合并结束列索引mergeBorder
- 是否合并边框public BaseExcelWriter<K,V> merge(org.apache.poi.ss.util.CellRangeAddress region, boolean mergeBorder)
region
- regionmergeBorder
- 是否合并边框public BaseExcelWriter<K,V> addRows(Collection<V> list)
list
- 行public BaseExcelWriter<K,V> addRow(V row)
row
- 行public BaseExcelWriter<K,V> header(HeaderOption option)
option
- optionpublic BaseExcelWriter<K,V> footer(FooterOption option)
option
- optionpublic BaseExcelWriter<K,V> print(PrintOption option)
option
- optionpublic BaseExcelWriter<K,V> protect(String password)
password
- passwordpublic BaseExcelWriter<K,V> displayGridLines()
public BaseExcelWriter<K,V> displayRowColHeadings()
public BaseExcelWriter<K,V> displayFormulas()
protected abstract Object getValue(V row, K key)
row
- rowkey
- keyIndexpublic org.apache.poi.ss.usermodel.CellStyle createCellStyle()
public org.apache.poi.ss.usermodel.Font createFont()
public org.apache.poi.ss.usermodel.DataFormat createFormat()
public org.apache.poi.ss.usermodel.Workbook getWorkbook()
public org.apache.poi.ss.usermodel.Sheet getSheet()
public int getLines()
public int getColumnMaxIndex()
public int getRowIndex()
Copyright © 2024. All rights reserved.