三角形横向时间轴定制
By:Roy.LiuLast updated:2019-10-24
public List importExcelWithMultipleSheet(InputStream is) throws Exception
{
this.type = Type.IMPORT;
this.wb = WorkbookFactory.create(is);
int sheetCount = wb.getNumberOfSheets();
List list = new ArrayList();
for(int c=0; c
Sheet sheet = wb.getSheetAt(c);
if (sheet == null){
throw new IOException("文件sheet不存在");
}
String sheetName = sheet.getSheetName();
if (StringUtils.isEmpty(sheetName)) {
throw new Exception("sheetName不能为空");
}
String[] oemModel = sheetName.split("-");
if (oemModel.length != 2) {
throw new Exception("sheetName命名不符合规范");
}
int rows = sheet.getPhysicalNumberOfRows();
if (rows > 0){
for (int i = 1; i < rows; i++)
{
// 从第2行开始取数据,默认第一行是表头. 第一列的数据就是MAC.
Row row = sheet.getRow(i);
T entity = null;
Object val = this.getCellValue(row, 0);
if (val != null) {
MacInfo obj = new MacInfo();
obj.setMac(val.toString());
obj.setModel(oemModel[1]);
obj.setOem(oemModel[0]);
list.add(obj);
}
}
}
}
return list;
}
{
this.type = Type.IMPORT;
this.wb = WorkbookFactory.create(is);
int sheetCount = wb.getNumberOfSheets();
List
for(int c=0; c
Sheet sheet = wb.getSheetAt(c);
if (sheet == null){
throw new IOException("文件sheet不存在");
}
String sheetName = sheet.getSheetName();
if (StringUtils.isEmpty(sheetName)) {
throw new Exception("sheetName不能为空");
}
String[] oemModel = sheetName.split("-");
if (oemModel.length != 2) {
throw new Exception("sheetName命名不符合规范");
}
int rows = sheet.getPhysicalNumberOfRows();
if (rows > 0){
for (int i = 1; i < rows; i++)
{
// 从第2行开始取数据,默认第一行是表头. 第一列的数据就是MAC.
Row row = sheet.getRow(i);
T entity = null;
Object val = this.getCellValue(row, 0);
if (val != null) {
MacInfo obj = new MacInfo();
obj.setMac(val.toString());
obj.setModel(oemModel[1]);
obj.setOem(oemModel[0]);
list.add(obj);
}
}
}
}
return list;
}
From:一号门
Previous:在javascript中放弃indexOf, 用$.inArray吧
Next:POI读取大数据EXCEL思路
COMMENTS