public class ExportExcel extends Object
| 构造器和说明 |
|---|
ExportExcel(String title,
Class<?> cls)
构造函数
|
ExportExcel(String title,
Class<?> cls,
int type,
int... groups)
构造函数
|
ExportExcel(String title,
List<String> headerList)
构造函数
|
ExportExcel(String title,
String[] headers)
构造函数
|
| 限定符和类型 | 方法和说明 |
|---|---|
org.apache.poi.ss.usermodel.Cell |
addCell(org.apache.poi.ss.usermodel.Row row,
int column,
Object val)
添加一个单元格
|
org.apache.poi.ss.usermodel.Cell |
addCell(org.apache.poi.ss.usermodel.Row row,
int column,
Object val,
int align,
Class<?> fieldType)
添加一个单元格
|
org.apache.poi.ss.usermodel.Row |
addRow()
添加一行
|
ExportExcel |
dispose()
清理临时文件
|
<E> ExportExcel |
setDataList(List<E> list)
添加数据(通过annotation.ExportField添加数据)
|
ExportExcel |
write(OutputStream os)
输出数据流
|
ExportExcel |
write(String fileName,
javax.servlet.http.HttpServletResponse response)
输出到客户端
|
ExportExcel |
writeFile(String name)
输出到文件
|
public ExportExcel(String title, Class<?> cls)
title - 表格标题,传“空值”,表示无标题cls - 实体对象,通过annotation.ExportField获取标题public ExportExcel(String title, Class<?> cls, int type, int... groups)
title - 表格标题,传“空值”,表示无标题cls - 实体对象,通过annotation.ExportField获取标题type - 导出类型(1:导出数据;2:导出模板)groups - 导入分组public ExportExcel(String title, String[] headers)
title - 表格标题,传“空值”,表示无标题headers - 表头数组public org.apache.poi.ss.usermodel.Row addRow()
public org.apache.poi.ss.usermodel.Cell addCell(org.apache.poi.ss.usermodel.Row row,
int column,
Object val)
row - 添加的行column - 添加列号val - 添加值public org.apache.poi.ss.usermodel.Cell addCell(org.apache.poi.ss.usermodel.Row row,
int column,
Object val,
int align,
Class<?> fieldType)
row - 添加的行column - 添加列号val - 添加值align - 对齐方式(1:靠左;2:居中;3:靠右)fieldType - 字段类型public <E> ExportExcel setDataList(List<E> list)
E - 泛型list - 参数public ExportExcel write(OutputStream os) throws IOException
os - 输出数据流IOException - 输出流异常public ExportExcel write(String fileName, javax.servlet.http.HttpServletResponse response) throws IOException
fileName - 输出文件名response - 响应IOException - 输出流异常public ExportExcel writeFile(String name) throws IOException
name - 输出文件名IOException - 输出流异常public ExportExcel dispose()
Copyright © 2017-6-20–2017. All rights reserved.