wb = new XSSFWorkbook(fs);
OPCPackage docPackage = OPCPackage.open(fs); wb = new XSSFWorkbook(docPackage);
	public ResultMessage addBuildingAndFloor(MultipartFile file) {		int rows = 1;		ResultMessage rm = new ResultMessage();		try {			InputStream fs = file.getInputStream();			String lastName= null;			Pattern pat = Pattern.compile("\\.[\\w]+");	 		Matcher m = pat.matcher(file.getOriginalFilename());			while(m.find()){				lastName = m.group();			}			Workbook wb = null ;			if(lastName.equals(".xls")){				wb = new HSSFWorkbook(fs);			}else if(lastName.equals(".xlsx")){				wb = new XSSFWorkbook(fs);			}else{				throw  new RuntimeException();			}						//第一行直接忽略			Sheet sheet1 = wb.getSheetAt(0);						for (int j=1;j<sheet1.getLastRowNum();j++) {				Row row = sheet1.getRow(j);								rows++;				int totalRoom = -1;				Area a = new Area();				Building b = new Building();				Floor f = new Floor();				Room r = new Room();								for (Cell cell : row) {					CellReference cellRef = new CellReference(row.getRowNum(),cell.getColumnIndex());					//只能用上固定的格式					switch(cellRef.getCol()){					case 0:a.setName(cell.toString());break;					case 1:b.setBuildingNum(String.valueOf(Math.round(Double.parseDouble(cell.toString()))));break;					case 2:f.setFloorNum(String.valueOf(Math.round(Double.parseDouble(cell.toString()))));break;					case 3:{								try {									totalRoom = Integer.parseInt(cell.toString());								} catch (Exception e) {									totalRoom = (int)Double.parseDouble(cell.toString());								}								break;							}					case 4:r.setTotalBed(cell.toString());break;					case 5:r.setCost(cell.toString());break;					case 6:b.setSex(cell.toString());break;					}				}								Area a2 = areaDao.addArea(a);				b.setArea(a2);				Building b2 = buildDao.addBuilding(b);								if(!floorDao.isFloorExist(f.getFloorNum(), b.getBuildingNum())){					f.setBuilding(b2);					floorDao.addFloor(f);				}				for(int i = 0;i<totalRoom;i++){					if(!roomService.addRoom(b.getBuildingNum(), f.getFloorNum(), r.getTotalBed(), r.getCost())){						throw new RuntimeException();					}				}			}						rm.setStatus(1);			rm.setInfo("成功");		} catch (IOException e) {			e.printStackTrace();			throw new RuntimeException();		} catch(NumberFormatException e){			e.printStackTrace();			rm.setStatus(0);			rm.setError("第"+rows+"行出了问题,可能输入有误请检查");			throw new RuntimeException();		} catch(Exception e){			e.printStackTrace();			rm.setStatus(0);			rm.setError("第"+rows+"行出了问题,可能输入有误请检查");			throw new RuntimeException();		} finally{			return rm;		}			}