利用HUtool讀取Excel內容


// 1.獲取上傳文件輸入流
InputStream inputStream = null;
try{
inputStream = file.getInputStream();
}catch (Exception e){
return ResponseData.fail(ResponseCodeEnum.ERROR_PARAM_INVALID);
}
// 2.應用HUtool ExcelUtil獲取ExcelReader指定輸入流和sheet
ExcelReader excelReader = ExcelUtil.getReader(inputStream, "知識點樹形列表");
// 可以加上表頭驗證
// 3.讀取第二行到最后一行數據
List<List<Object>> read = excelReader.read(2, excelReader.getRowCount());
for (List<Object> objects : read) {
// objects.get(0),讀取某行第一列數據
// objects.get(1),讀取某行第二列數據
}


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM