public class ExcelProcessor extends Object
限定符和类型 | 字段和说明 |
---|---|
static String |
EXTENSION_XLS
2003格式的excel文件
|
static String |
EXTENSION_XLSX
2007格式的excel文件
|
限定符和类型 | 方法和说明 |
---|---|
static void |
exportExcel(Map<String,String> headers,
Collection<Map<String,Object>> list,
Map<Integer,Short> rowColorStyleMap,
Map<Integer,Short> rowHeightStyleMap,
Map<Integer,Integer> colWidthStyleMap,
OutputStream out,
String type)
将放置在JAVA集合中并且符合一定条件的数据以EXCEL的形式输出到指定IO设备上,用于单个sheet
|
static void |
exportExcel(Map<String,String> headers,
Collection<Map<String,Object>> list,
Map<Integer,Short> rowColorStyleMap,
Map<Integer,Short> rowHeightStyleMap,
Map<Integer,Integer> colWidthStyleMap,
Set<String> imageColSet,
OutputStream out,
String type)
将放置在JAVA集合中并且符合一定条件的数据以EXCEL的形式输出到指定IO设备上,用于单个sheet
|
static void |
exportExcel(Map<String,String> headers,
Collection<Map<String,Object>> list,
Map<Integer,Short> rowColorStyleMap,
Map<Integer,Short> rowHeightStyleMap,
Map<Integer,Integer> colWidthStyleMap,
Set<String> imageColSet,
OutputStream out,
String pattern,
String type)
将放置在JAVA集合中并且符合一定条件的数据以EXCEL的形式输出到指定IO设备上,用于单个sheet
|
static void |
exportExcel(Map<String,String> headers,
Collection<Map<String,Object>> list,
Map<Integer,Short> rowColorStyleMap,
Map<Integer,Short> rowHeightStyleMap,
OutputStream out,
String type)
将放置在JAVA集合中并且符合一定条件的数据以EXCEL的形式输出到指定IO设备上,用于单个sheet
|
static void |
exportExcel(Map<String,String> headers,
Collection<Map<String,Object>> list,
Map<Integer,Short> rowColorStyleMap,
OutputStream out,
String type)
将放置在JAVA集合中并且符合一定条件的数据以EXCEL的形式输出到指定IO设备上,用于单个sheet
|
static void |
exportExcel(Map<String,String> headers,
Collection<Map<String,Object>> list,
OutputStream out,
String type)
将放置在JAVA集合中并且符合一定条件的数据以EXCEL的形式输出到指定IO设备上,用于单个sheet
|
static String |
getCellValue(org.apache.poi.ss.usermodel.Cell cell,
boolean treatAsStr)
取单元格的值
|
static ArrayList<String[]> |
getTableData(File file)
将excel表格的内容按照最简单的行列模式,构造二维集合返回,集合中一个元素代表一行数据
|
static ArrayList<String[]> |
getTableData(File file,
int sheetIndex)
将excel表格的内容按照最简单的行列模式,构造二维集合返回,集合中一个元素代表一行数据
|
static org.apache.poi.ss.usermodel.Workbook |
getWorkbook(File file)
取得Workbook对象(xls和xlsx对象不同,不过都是Workbook的实现类) xls:HSSFWorkbook
xlsx:XSSFWorkbook,该方法不适合处理大数据量的文件
|
static void |
verifyFile(File file)
验证文件有效性
|
public static void verifyFile(File file)
file
- excel文件public static org.apache.poi.ss.usermodel.Workbook getWorkbook(File file) throws IOException
file
- excel文档IOException
- 文档读取过程中,可能发生异常public static String getCellValue(org.apache.poi.ss.usermodel.Cell cell, boolean treatAsStr)
cell
- 单元格对象treatAsStr
- 为true时,当做文本来取值 (取到的是文本,不会把“1”取成“1.0”)public static ArrayList<String[]> getTableData(File file) throws IOException
file
- excel文档IOException
- 获取数据过程中可能会抛出该异常public static ArrayList<String[]> getTableData(File file, int sheetIndex) throws IOException
file
- excel文档sheetIndex
- sheet索引IOException
- 获取数据过程中可能会抛出该异常public static void exportExcel(Map<String,String> headers, Collection<Map<String,Object>> list, OutputStream out, String type) throws IOException
headers
- 表格属性列名数组list
- 需要显示的数据集合,集合中一定要放置符合javabean风格的类的对象。此方法支持的
javabean属性的数据类型有基本数据类型及String,Date,String[],Double[]out
- 与输出设备关联的流对象,可以将EXCEL文档导出到本地文件或者网络中type
- excel文件类型IOException
- 文档处理过程中,可能发生异常public static void exportExcel(Map<String,String> headers, Collection<Map<String,Object>> list, Map<Integer,Short> rowColorStyleMap, OutputStream out, String type) throws IOException
headers
- 表格属性列名数组list
- 需要显示的数据集合,集合中一定要放置符合javabean风格的类的对象。此方法支持的
javabean属性的数据类型有基本数据类型及String,Date,String[],Double[]rowColorStyleMap
- 行的背景颜色风格out
- 与输出设备关联的流对象,可以将EXCEL文档导出到本地文件或者网络中type
- excel文件类型IOException
- 文档处理过程中,可能发生异常public static void exportExcel(Map<String,String> headers, Collection<Map<String,Object>> list, Map<Integer,Short> rowColorStyleMap, Map<Integer,Short> rowHeightStyleMap, OutputStream out, String type) throws IOException
headers
- 表格属性列名数组list
- 需要显示的数据集合,集合中一定要放置符合javabean风格的类的对象。此方法支持的
javabean属性的数据类型有基本数据类型及String,Date,String[],Double[]rowColorStyleMap
- 行的背景颜色风格rowHeightStyleMap
- 行的高度风格out
- 与输出设备关联的流对象,可以将EXCEL文档导出到本地文件或者网络中type
- excel文件类型IOException
- 文档处理过程中,可能发生异常public static void exportExcel(Map<String,String> headers, Collection<Map<String,Object>> list, Map<Integer,Short> rowColorStyleMap, Map<Integer,Short> rowHeightStyleMap, Map<Integer,Integer> colWidthStyleMap, OutputStream out, String type) throws IOException
headers
- 表格属性列名数组list
- 需要显示的数据集合,集合中一定要放置符合javabean风格的类的对象。此方法支持的
javabean属性的数据类型有基本数据类型及String,Date,String[],Double[]rowColorStyleMap
- 行的背景颜色风格rowHeightStyleMap
- 行的高度风格colWidthStyleMap
- 列的宽度风格,指定列需要占几个字符宽度out
- 与输出设备关联的流对象,可以将EXCEL文档导出到本地文件或者网络中type
- excel文件类型IOException
- 文档处理过程中,可能发生异常public static void exportExcel(Map<String,String> headers, Collection<Map<String,Object>> list, Map<Integer,Short> rowColorStyleMap, Map<Integer,Short> rowHeightStyleMap, Map<Integer,Integer> colWidthStyleMap, Set<String> imageColSet, OutputStream out, String type) throws IOException
headers
- 表格属性列名数组list
- 需要显示的数据集合,集合中一定要放置符合javabean风格的类的对象。此方法支持的
javabean属性的数据类型有基本数据类型及String,Date,String[],Double[]rowColorStyleMap
- 行的背景颜色风格rowHeightStyleMap
- 行的高度风格colWidthStyleMap
- 列的宽度风格,指定列需要占几个字符宽度imageColSet
- 图片列,以标题为标识out
- 与输出设备关联的流对象,可以将EXCEL文档导出到本地文件或者网络中type
- excel文件类型IOException
- 文档处理过程中,可能发生异常public static void exportExcel(Map<String,String> headers, Collection<Map<String,Object>> list, Map<Integer,Short> rowColorStyleMap, Map<Integer,Short> rowHeightStyleMap, Map<Integer,Integer> colWidthStyleMap, Set<String> imageColSet, OutputStream out, String pattern, String type) throws IOException
headers
- 表格属性列名数组list
- 需要显示的数据集合,集合中一定要放置符合javabean风格的类的对象。此方法支持的
javabean属性的数据类型有基本数据类型及String,Date,String[],Double[]rowColorStyleMap
- 行的背景颜色风格rowHeightStyleMap
- 行的高度风格colWidthStyleMap
- 列的宽度风格,指定列需要占几个字符宽度imageColSet
- 图片列,以标题为标识out
- 与输出设备关联的流对象,可以将EXCEL文档导出到本地文件或者网络中pattern
- 如果有时间数据,设定输出格式。默认为"yyyy-MM-dd"type
- excel文件类型IOException
- 文档处理过程中,可能发生异常