Package icu.easyj.poi.excel.converter
Class ExcelConverterUtils
java.lang.Object
icu.easyj.poi.excel.converter.ExcelConverterUtils
Excel转换器工具类
- Author:
- wangliang181230
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic IExcelConvertergetConverter(Class<?> clazz) 获取类对应的转换器static <T> org.apache.poi.ss.usermodel.Workbook列表转换为Excel的workbook实例static <T> List<T>Excel文件转换为列表数据static <T> List<T>toList(InputStream inputStream, Class<T> clazz) Excel文件转换为列表数据
-
Constructor Details
-
ExcelConverterUtils
public ExcelConverterUtils()
-
-
Method Details
-
getConverter
@NonNull public static IExcelConverter getConverter(@NonNull Class<?> clazz) throws ConverterNotFoundException 获取类对应的转换器- Parameters:
clazz- 数据类型- Returns:
- excelConverter excel转换器
- Throws:
ConverterNotFoundException- 转换器不存在或未匹配
-
toList
public static <T> List<T> toList(InputStream inputStream, Class<T> clazz) throws ConvertException, ConverterNotFoundException Excel文件转换为列表数据- Type Parameters:
T- 数据类型- Parameters:
inputStream- Excel文件流clazz- 数据类- Returns:
- list 列表数据
- Throws:
ConverterNotFoundException- 转换器不存在 或 未匹配到合适的转换器ConvertException- 转换失败的异常
-
toList
public static <T> List<T> toList(byte[] excelFileBytes, Class<T> clazz) throws ConvertException, ConverterNotFoundException Excel文件转换为列表数据- Type Parameters:
T- 数据类型- Parameters:
excelFileBytes- Excel文件byte数组clazz- 数据类- Returns:
- list 列表数据
- Throws:
ConverterNotFoundException- 转换器不存在 或 未匹配到合适的转换器ConvertException- 转换失败的异常
-
toExcel
public static <T> org.apache.poi.ss.usermodel.Workbook toExcel(List<T> list, Class<T> clazz) throws ConvertException, ConverterNotFoundException 列表转换为Excel的workbook实例- Type Parameters:
T- 数据类型- Parameters:
list- 列表数据clazz- 数据类- Returns:
- excel的workbook实例
- Throws:
ConverterNotFoundException- 转换器不存在 或 未匹配到合适的转换器ConvertException- 转换失败的异常
-