public class ExcelTool extends Object
| 限定符和类型 | 方法和说明 |
|---|---|
static org.apache.poi.ss.usermodel.Workbook |
buildWorkbook(File file)
创建 Workbook
|
static org.apache.poi.ss.usermodel.Workbook |
buildWorkbook(InputStream inputStream)
创建 Workbook
|
static void |
exportToOutputStream(org.apache.poi.ss.usermodel.Workbook workbook,
File file)
导出文件
|
static void |
exportToOutputStream(org.apache.poi.ss.usermodel.Workbook workbook,
OutputStream outputStream)
导出至输出流
|
static String |
formatNumeric(Double numericCellValue) |
static Byte |
getByteValue(org.apache.poi.ss.usermodel.Row row,
int cellIndex) |
static org.apache.poi.ss.usermodel.Cell |
getCell(org.apache.poi.ss.usermodel.Row row,
int index)
获取 cell 对象
|
static Date |
getDateValue(org.apache.poi.ss.usermodel.Row row,
int cellIndex) |
static Double |
getDoubleValue(org.apache.poi.ss.usermodel.Row row,
int cellIndex) |
static String |
getFormatDateValue(org.apache.poi.ss.usermodel.Row row,
int cellIndex) |
static String |
getFormatDateValue(org.apache.poi.ss.usermodel.Row row,
int cellIndex,
String pattern) |
static Integer |
getIntegerValue(org.apache.poi.ss.usermodel.Row row,
int cellIndex) |
static Long |
getLongValue(org.apache.poi.ss.usermodel.Row row,
int cellIndex) |
static String |
getStringValue(org.apache.poi.ss.usermodel.Row row,
int cellIndex) |
static <T> List<T> |
parseData(InputStream inputStream,
java.util.function.BiFunction<Integer,org.apache.poi.ss.usermodel.Row,T> function)
解析 excel 中的内容为 list 集合数据
默认解析:
第一个 sheet
跳过第一行数据
|
static <T> List<T> |
parseData(InputStream inputStream,
Class<T> clazz)
解析数据
|
static <T> List<T> |
parseData(String filePath,
java.util.function.BiFunction<Integer,org.apache.poi.ss.usermodel.Row,T> function)
解析 excel 中的内容为 list 集合数据
默认解析:
第一个 sheet
跳过第一行数据
|
static <T> List<T> |
parseData(String filePath,
int sheetIndex,
int skipLineNumbers,
java.util.function.BiFunction<Integer,org.apache.poi.ss.usermodel.Row,T> function)
解析 excel 中的内容为 list 集合数据
|
public static <T> List<T> parseData(String filePath, java.util.function.BiFunction<Integer,org.apache.poi.ss.usermodel.Row,T> function)
T - 返回数据泛型filePath - 文件路径function - 解析接口public static <T> List<T> parseData(InputStream inputStream, java.util.function.BiFunction<Integer,org.apache.poi.ss.usermodel.Row,T> function)
T - 返回数据泛型inputStream - 文件输入流function - 解析接口public static <T> List<T> parseData(InputStream inputStream, Class<T> clazz)
T - 解析数据对象类型泛型inputStream - 输入流clazz - 解析数据对象类型public static void exportToOutputStream(org.apache.poi.ss.usermodel.Workbook workbook,
File file)
workbook - Workbookfile - 目标文件public static void exportToOutputStream(org.apache.poi.ss.usermodel.Workbook workbook,
OutputStream outputStream)
workbook - WorkbookoutputStream - 输出流public static <T> List<T> parseData(String filePath, int sheetIndex, int skipLineNumbers, java.util.function.BiFunction<Integer,org.apache.poi.ss.usermodel.Row,T> function)
T - 返回数据泛型filePath - 文件路径sheetIndex - sheet索引skipLineNumbers - 跳过第几行(物理行数)function - 解析接口public static org.apache.poi.ss.usermodel.Cell getCell(org.apache.poi.ss.usermodel.Row row,
int index)
row - Row 对象index - cell 所在索引public static String getStringValue(org.apache.poi.ss.usermodel.Row row, int cellIndex)
public static Byte getByteValue(org.apache.poi.ss.usermodel.Row row, int cellIndex)
public static Long getLongValue(org.apache.poi.ss.usermodel.Row row, int cellIndex)
public static Double getDoubleValue(org.apache.poi.ss.usermodel.Row row, int cellIndex)
public static Integer getIntegerValue(org.apache.poi.ss.usermodel.Row row, int cellIndex)
public static Date getDateValue(org.apache.poi.ss.usermodel.Row row, int cellIndex)
public static String getFormatDateValue(org.apache.poi.ss.usermodel.Row row, int cellIndex)
public static String getFormatDateValue(org.apache.poi.ss.usermodel.Row row, int cellIndex, String pattern)
public static org.apache.poi.ss.usermodel.Workbook buildWorkbook(InputStream inputStream)
inputStream - 输入流public static org.apache.poi.ss.usermodel.Workbook buildWorkbook(File file)
file - 文件Copyright © 2022. All rights reserved.