数据的样子是这样的
public String addReportByExcel(Long userId,InputStream inputStream,String fileName)
throws BusinessException{
String message = "Import success";
boolean isE2007 = false; //判断是否是excel2007格式
if(fileName.endsWith("xlsx")){
isE2007 = true;
}
int rowIndex = 0;
int columnIndex = 0;
try {
InputStream input = inputStream; //建立输入流
Workbook wb = null;
//根据文件格式(2003或者2007)来初始化
if(isE2007){
wb = new XSSFWorkbook(input);
}else{
wb = new HSSFWorkbook(input);
}
Sheet sheet = wb.getSheetAt(0); //获得第一个表单
//System.out.println("总行数:"+sheet.getLastRowNum());
List<CellRangeAddress> cras = getCombineCell(sheet);
//isMergedRegion(Sheet sheet,int row ,int column);判断是不是合并单元格\
int count = sheet.getLastRowNum()+1;//总行数
List<InspectionReport> irs = new ArrayList<>();
for(int i = 1; i < count;i++){
rowIndex = i;
Row row = sheet.getRow(i);
InspectionReport ir = new InspectionReport();
ir.setReportName(getCellValue(row.getCell(0)));
ir.setShift(Double.valueOf(getCellValue(row.getCell(1))).intValue());
ir.setLine(getCellValue(row.getCell(2)));
ir.setStationCode(getCellValue(row.getCell(3)));
ir.setArea(Double.valueOf(getCellValue(row.getCell(4))).intValue());