看你的程式碼,似乎實現的是要讀取Excel檔吧。程式碼如下:具體的跟你的POI所支援的EXCEL版本有關係的。 public List importExcel(@File("upload")FileItem fileInput, ErrorContext error) { List list = null;
if (null == fileInput) {
throw new ServiceException(ErrorCode.Params_Lost, "机柜导入文件");
}
Workbook wb = null;
InputStream is = null;
Sheet sheet = null;
try {
is = fileInput.getInputStream();
wb = new XSSFWorkbook(is);
sheet = wb.getSheet(sheetName);
} catch (Exception e) {
throw new ServiceException(ErrorCode.Upload_File_Error, "上传excel版本文件解析失败");
} finally {
if (is != null) {
try {
is.close();
} catch (IOException e) {
}
}
}
if (sheet != null) {
// 初始化Excel栏目
List<CellMapping> mappingList = RackUtil.getModColumns(null);
try {
list = ExcelUtils.excel2bean(sheet, RackVo.class, mappingList);
} catch (Exception e) {
throw new ServiceException(ErrorCode.Upload_File_Error, "Excel解析失败");
}
} else {
throw new ServiceException(ErrorCode.Upload_File_Error, "未找到模板对应sheet");
}
return list;
看你的程式碼,似乎實現的是要讀取Excel檔吧。程式碼如下:具體的跟你的POI所支援的EXCEL版本有關係的。 importExcel(@File("upload")FileItem fileInput, ErrorContext error) { list = null;
public List
List
}