Search in sources :

Example 1 with StringExcelListener

use of cn.ruiyeclub.listener.StringExcelListener in project SpringBoot-Hello by ruiyeclub.

the class ExcelUtil method readExcel.

/**
 * @param inputStream   Excel的输入流
 * @param excelTypeEnum Excel的格式(XLS或XLSX)
 * @Description: 使用 StringList 来读取Excel
 * @Date: 2020/1/16 21:40
 * @Return: java.util.List<java.util.List < java.lang.String>>
 * @Throws: Exception
 */
public static List<List<String>> readExcel(InputStream inputStream, ExcelTypeEnum excelTypeEnum) throws Exception {
    StringExcelListener listener = new StringExcelListener();
    ExcelReader excelReader = new ExcelReader(inputStream, excelTypeEnum, null, listener);
    excelReader.read();
    return listener.getDatas();
}
Also used : ExcelReader(com.alibaba.excel.ExcelReader) StringExcelListener(cn.ruiyeclub.listener.StringExcelListener)

Aggregations

StringExcelListener (cn.ruiyeclub.listener.StringExcelListener)1 ExcelReader (com.alibaba.excel.ExcelReader)1