excel解析二维数组结构的excel
public void fileImport(Ufile ufile) throws Exception {
String filePath = ufile.getFilePath();
List<AuthTransaction> parseResult = ExcelUtils.parseExcelInterface(filePath, new ParseExcelSheets<AuthTransaction>() {
@Override
public List<AuthTransaction> doParse(List<Sheet> sheets) {
List<AuthTransaction> tempResult = new ArrayList<AuthTransaction>();
DecimalFormat df = new DecimalFormat("0");
for (Sheet sheet : sheets) {
int rowCount = sheet.getPhysicalNumberOfRows();// 总行数
int startRowIndex = 1;
int endRowIndex = rowCount;
int startColumnIndex = 0;
int endColumnIndex = 50;
for (int i = startRowIndex; i < endRowIndex; i++) {
try {
int flag=0;
AuthTransaction authTransaction = new AuthTransaction();
Row row = sheet.getRow(i);
if(row==null){
break;
}
for (int j = startColumnIndex; j < endColumnIndex; j++) {
Cell cell = row.getCell(j);
if(cell==null){
flag=1;
break;
}
switch (j % endColumnIndex) {
case 0:// 年份 ->编号
if (cell.getCellType() == Cell.CELL_TYPE_NUMERIC) {
df = new DecimalFormat("########");
String cellValue = df.format(cell.getNumericCellValue());
authTransaction.setAuthApplicationNo(cellValue);
flag=0;
break;
//authTransaction.setAuthApplicationYear(cellValue);
} else if (cell.getCellType() == Cell.CELL_TYPE_STRING && StringUtils.isNotBlank(cell.getStringCellValue())) {
String cellValue = cell.getStringCellValue().trim();
if (DataUtils.isInteger(cellValue)) {
authTransaction.setAuthApplicationNo(cellValue);
}
flag=0;
break;
}else{
flag=1;
break;
}
case 1:// 编号->船名
if (cell != null && cell.getCellType() == Cell.CELL_TYPE_STRING && StringUtils.isNotBlank(cell.getStringCellValue())) {
String cellValue = cell.getStringCellValue().trim();
authTransaction.setShipName(cellValue);
//authTransaction.setAuthApplicationNo(cellValue);
}
break;
case 2:// 船名->船舶类型
if (cell != null && cell.getCellType() == Cell.CELL_TYPE_STRING && StringUtils.isNotBlank(cell.getStringCellValue())) {
String cellValue = cell.getStringCellValue().trim();
authTransaction.setShipTypeName(cellValue);
Dictionary dictionary = dictionaryService.getEntityByName(cellValue);
if (dictionary != null) {
authTransaction.setShipTypeId(dictionary.getId());
} else {
throw new ServiceException("请先在用户字典中维护船型:" + cellValue);
}
}
else {
throw new ServiceException(authTransaction.getShipName() + "为设置船型");
}
break;
/*if (cell != null && cell.getCellType() == Cell.CELL_TYPE_STRING && StringUtils.isNotBlank(cell.getStringCellValue())) {
String cellValue = cell.getStringCellValue().trim();
authTransaction.setShipName(cellValue);
}
break;*/
case 3:// 曾用名->船舶识别号
if (cell != null && cell.getCellType() == Cell.CELL_TYPE_STRING && StringUtils.isNotBlank(cell.getStringCellValue())) {
String cellValue = cell.getStringCellValue().trim();
authTransaction.setShipRegisterNo(cellValue);
} else if (cell != null && cell.getCellType() == Cell.CELL_TYPE_NUMERIC) {
String cellValue = df.format(cell.getNumericCellValue());
authTransaction.setShipRegisterNo(cellValue);
}
break;
/*if (cell != null && cell.getCellType() == Cell.CELL_TYPE_STRING && StringUtils.isNotBlank(cell.getStringCellValue())) {
String cellValue = cell.getStringCellValue().trim();
authTransaction.setShipFormerName(cellValue);
}
break;*/
case 4:// 船型->初次登记号码
if (cell != null && cell.getCellType() == Cell.CELL_TYPE_STRING && StringUtils.isNotBlank(cell.getStringCellValue())) {
String cellValue = cell.getStringCellValue().trim();
authTransaction.setFirstRegisterNo(cellValue);
} else if (cell != null && cell.getCellType() == Cell.CELL_TYPE_NUMERIC) {
String cellValue = df.format(cell.getNumericCellValue());
authTransaction.setFirstRegisterNo(cellValue);
}
break;
/*if (cell != null && cell.getCellType() == Cell.CELL_TYPE_STRING && StringUtils.isNotBlank(cell.getStringCellValue())) {
String cellValue = cell.getStringCellValue().trim();
authTransaction.setShipTypeName(cellValue);
Dictionary dictionary = dictionaryService.getEntityByName(cellValue);
if (dictionary != null) {
authTransaction.setShipTypeId(dictionary.getId());
} else {
throw new ServiceException("请先在用户字典中维护船型:" + cellValue);
}
} else {
throw new ServiceException(authTransaction.getShipName() + "为设置船型");
}
break;*/
case 5:// 船舶登记号->总吨
if (cell != null) {
if (cell.getCellType() == Cell.CELL_TYPE_NUMERIC) {
authTransaction.setGrossTon(cell.getNumericCellValue());
} else if (cell.getCellType() == Cell.CELL_TYPE_STRING && StringUtils.isNotBlank(cell.getStringCellValue())) {
String cellValue = cell.getStringCellValue().trim();
if (DataUtils.isNumeric(cellValue)) {
authTransaction.setGrossTon(Double.valueOf(cellValue));
}
}
}
break;
/*if (cell != null && cell.getCellType() == Cell.CELL_TYPE_STRING && StringUtils.isNotBlank(cell.getStringCellValue())) {
String cellValue = cell.getStringCellValue().trim();
authTransaction.setShipRegisterNo(cellValue);
} else if (cell != null && cell.getCellType() == Cell.CELL_TYPE_NUMERIC) {
String cellValue = df.format(cell.getNumericCellValue());
authTransaction.setShipRegisterNo(cellValue);
}
break;*/
case 6:// 总吨 ->净吨
if (cell != null) {
if (cell.getCellType() == Cell.CELL_TYPE_NUMERIC) {
authTransaction.setNetTon(cell.getNumericCellValue());
} else if (cell.getCellType() == Cell.CELL_TYPE_STRING && StringUtils.isNotBlank(cell.getStringCellValue())) {
String cellValue = cell.getStringCellValue().trim();
if (DataUtils.isNumeric(cellValue)) {
authTransaction.setNetTon(cell.getNumericCellValue());
}
}
}
break;
/* if (cell != null) {
if (cell.getCellType() == Cell.CELL_TYPE_NUMERIC) {
authTransaction.setGrossTon(cell.getNumericCellValue());
} else if (cell.getCellType() == Cell.CELL_TYPE_STRING && StringUtils.isNotBlank(cell.getStringCellValue())) {
String cellValue = cell.getStringCellValue().trim();
if (DataUtils.isNumeric(cellValue)) {
authTransaction.setGrossTon(Double.valueOf(cellValue));
}
}
}
break;*/
case 7:// 载重吨
if (cell != null) {
if (cell.getCellType() == Cell.CELL_TYPE_NUMERIC) {
authTransaction.setDeadWeight(cell.getNumericCellValue());
} else if (cell.getCellType() == Cell.CELL_TYPE_STRING && StringUtils.isNotBlank(cell.getStringCellValue())) {
String cellValue = cell.getStringCellValue().trim();
if (DataUtils.isNumeric(cellValue)) {
authTransaction.setDeadWeight(Double.valueOf(cellValue));
}
}
}
break;
case 8:// 船龄-> 成交价格
if (cell != null) {
if (cell.getCellType() == Cell.CELL_TYPE_NUMERIC) {
String cellValue = df.format(cell.getNumericCellValue());
if (DataUtils.isInteger(cellValue)) {
authTransaction.setPrice(Double.valueOf(cellValue));
}
} else if (cell.getCellType() == Cell.CELL_TYPE_STRING && StringUtils.isNotBlank(cell.getStringCellValue())) {
String cellValue = cell.getStringCellValue().trim();
if (DataUtils.isInteger(cellValue)) {
authTransaction.setPrice(Double.valueOf(cellValue));
}
}
}
break;
/*if (cell != null) {
if (cell.getCellType() == Cell.CELL_TYPE_NUMERIC) {
String cellValue = df.format(cell.getNumericCellValue());
if (DataUtils.isInteger(cellValue)) {
authTransaction.setShipAge(Integer.valueOf(cellValue));
}
} else if (cell.getCellType() == Cell.CELL_TYPE_STRING && StringUtils.isNotBlank(cell.getStringCellValue())) {
String cellValue = cell.getStringCellValue().trim();
if (DataUtils.isInteger(cellValue)) {
authTransaction.setShipAge(Integer.valueOf(cellValue));
}
}
}
break;*/
case 9:// 建造年份->成交日期
if (cell != null && HSSFDateUtil.isCellDateFormatted(cell)) {
authTransaction.setTradeDate(cell.getDateCellValue());
}
break;
/*if (cell != null && HSSFDateUtil.isCellDateFormatted(cell)) {
authTransaction.setBuildDate(cell.getDateCellValue());
}
break;*/
case 10:// 建造船厂->鉴证费
/*if (cell != null && cell.getCellType() == Cell.CELL_TYPE_STRING && StringUtils.isNotBlank(cell.getStringCellValue())) {
String cellValue = cell.getStringCellValue().trim();
authTransaction.setBuildShipyard(cellValue);
}
break;*/
if (cell != null) {
if (cell.getCellType() == Cell.CELL_TYPE_NUMERIC) {
authTransaction.setAuthCharge(cell.getNumericCellValue());
} else if (cell.getCellType() == Cell.CELL_TYPE_STRING && StringUtils.isNotBlank(cell.getStringCellValue())) {
String cellValue = cell.getStringCellValue().trim();
if (DataUtils.isNumeric(cellValue)) {
authTransaction.setAuthCharge(Double.valueOf(cellValue));
}
}
}
break;
case 11:// 船籍港->鉴证日期
/*if (cell != null && cell.getCellType() == Cell.CELL_TYPE_STRING && StringUtils.isNotBlank(cell.getStringCellValue())) {
String cellValue = cell.getStringCellValue().trim();
authTransaction.setHomePort(cellValue);
}
break;*/
if (cell != null && HSSFDateUtil.isCellDateFormatted(cell)) {
authTransaction.setAuthDate(cell.getDateCellValue());
}
break;
case 12:// 海、河船->船龄
if (cell != null) {
df = new DecimalFormat("#.0");
String cellValue = df.format(cell.getNumericCellValue());
authTransaction.setShipAge(Double.valueOf(cellValue));
/*if (cell.getCellType() == Cell.CELL_TYPE_NUMERIC) {
if (DataUtils.isNumeric(cellValue)) {
authTransaction.setShipAge(Double.valueOf(cellValue));
}
} else if (cell.getCellType() == Cell.CELL_TYPE_STRING && StringUtils.isNotBlank(cell.getStringCellValue())) {
cellValue = cell.getStringCellValue().trim();
if (DataUtils.isNumeric(cellValue)) {
authTransaction.setShipAge(Double.valueOf(cellValue));
}
}*/
}
break;
/*authTransaction.setIsShip(0);//默认河船
if (cell != null && cell.getCellType() == Cell.CELL_TYPE_STRING && StringUtils.isNotBlank(cell.getStringCellValue())) {
String cellValue = cell.getStringCellValue().trim();
if (cellValue.equals("海船")) {
authTransaction.setIsShip(1);
}
}
break;*/
case 13:// 船级->建造年份
if (cell != null && HSSFDateUtil.isCellDateFormatted(cell)) {
authTransaction.setBuildDate(cell.getDateCellValue());
}
break;
/*if (cell != null && cell.getCellType() == Cell.CELL_TYPE_STRING && StringUtils.isNotBlank(cell.getStringCellValue())) {
String cellValue = cell.getStringCellValue().trim();
authTransaction.setClassificationSociety(cellValue);
}
break;*/
case 14:// 航区 ->建造船厂
if (cell != null && cell.getCellType() == Cell.CELL_TYPE_STRING && StringUtils.isNotBlank(cell.getStringCellValue())) {
String cellValue = cell.getStringCellValue().trim();
authTransaction.setBuildShipyard(cellValue);
}
break;
/*if (cell != null && cell.getCellType() == Cell.CELL_TYPE_STRING && StringUtils.isNotBlank(cell.getStringCellValue())) {
String cellValue = cell.getStringCellValue().trim();
authTransaction.setNavigationArea(cellValue);
}
break;*/
case 15:// 总长->建造地点
if (cell != null && cell.getCellType() == Cell.CELL_TYPE_STRING && StringUtils.isNotBlank(cell.getStringCellValue())) {
String cellValue = cell.getStringCellValue().trim();
authTransaction.setBuildArea(cellValue);
}
break;
/*if (cell != null) {
if (cell.getCellType() == Cell.CELL_TYPE_NUMERIC) {
authTransaction.setShipLength(cell.getNumericCellValue());
} else if (cell.getCellType() == Cell.CELL_TYPE_STRING && StringUtils.isNotBlank(cell.getStringCellValue())) {
String cellValue = cell.getStringCellValue().trim();
if (DataUtils.isNumeric(cellValue)) {
authTransaction.setShipLength(Double.valueOf(cellValue));
}
}
}
break;*/
case 16:// 型宽->船名(原)
if (cell != null && cell.getCellType() == Cell.CELL_TYPE_STRING && StringUtils.isNotBlank(cell.getStringCellValue())) {
String cellValue = cell.getStringCellValue().trim();
authTransaction.setShipFormerName(cellValue);
}
break;
/*if (cell != null) {
if (cell.getCellType() == Cell.CELL_TYPE_NUMERIC) {
authTransaction.setShipWidth(cell.getNumericCellValue());
} else if (cell.getCellType() == Cell.CELL_TYPE_STRING && StringUtils.isNotBlank(cell.getStringCellValue())) {
String cellValue = cell.getStringCellValue().trim();
if (DataUtils.isNumeric(cellValue)) {
authTransaction.setShipWidth(Double.valueOf(cellValue));
}
}
}
break;*/
case 17:// 型深->船名(现)不解析
/*if (cell != null) {
if (cell.getCellType() == Cell.CELL_TYPE_NUMERIC) {
authTransaction.setShipHeight(cell.getNumericCellValue());
} else if (cell.getCellType() == Cell.CELL_TYPE_STRING && StringUtils.isNotBlank(cell.getStringCellValue())) {
String cellValue = cell.getStringCellValue().trim();
if (DataUtils.isNumeric(cellValue)) {
authTransaction.setShipHeight(Double.valueOf(cellValue));
}
}
}*/
break;
case 18:// 主机型号->船籍港(原)
if (cell != null && cell.getCellType() == Cell.CELL_TYPE_STRING && StringUtils.isNotBlank(cell.getStringCellValue())) {
String cellValue = cell.getStringCellValue().trim();
authTransaction.setHomePort(cellValue);
}
break;
/* if (cell != null && cell.getCellType() == Cell.CELL_TYPE_STRING && StringUtils.isNotBlank(cell.getStringCellValue())) {
String cellValue = cell.getStringCellValue().trim();
authTransaction.setHostModel(cellValue);
}
break;*/
case 19:// 主机功率—>船籍港(现)不解析
/*if (cell != null) {
if (cell.getCellType() == Cell.CELL_TYPE_NUMERIC) {
authTransaction.setHostPower(cell.getNumericCellValue());
} else if (cell.getCellType() == Cell.CELL_TYPE_STRING && StringUtils.isNotBlank(cell.getStringCellValue())) {
String cellValue = cell.getStringCellValue().trim();
if (DataUtils.isNumeric(cellValue)) {
authTransaction.setHostPower(Double.valueOf(cellValue));
}
}
}
break;*/
case 20:// 主机转速->海/河船
authTransaction.setIsShip(0);//默认河船
if (cell != null && cell.getCellType() == Cell.CELL_TYPE_STRING && StringUtils.isNotBlank(cell.getStringCellValue())) {
String cellValue = cell.getStringCellValue().trim();
if (cellValue.equals("海船")) {
authTransaction.setIsShip(1);
}
}
break;
/*if (cell != null && cell.getCellType() == Cell.CELL_TYPE_STRING && StringUtils.isNotBlank(cell.getStringCellValue())) {
String cellValue = cell.getStringCellValue().trim();
authTransaction.setShipRateType(cellValue);
}
break;*/
/*if (cell != null) {
if (cell.getCellType() == Cell.CELL_TYPE_NUMERIC) {
authTransaction.setHostSpeed(cell.getNumericCellValue());
} else if (cell.getCellType() == Cell.CELL_TYPE_STRING && StringUtils.isNotBlank(cell.getStringCellValue())) {
String cellValue = cell.getStringCellValue().trim();
if (DataUtils.isNumeric(cellValue)) {
authTransaction.setHostSpeed(Double.valueOf(cellValue));
}
}
}
break;*/
case 21:// 主机台数->船检机构
if (cell != null && cell.getCellType() == Cell.CELL_TYPE_STRING && StringUtils.isNotBlank(cell.getStringCellValue())) {
String cellValue = cell.getStringCellValue().trim();
authTransaction.setShipCheck(cellValue);
}
break;
/*if (cell != null) {
if (cell.getCellType() == Cell.CELL_TYPE_NUMERIC) {
String cellValue = df.format(cell.getNumericCellValue());
if (DataUtils.isInteger(cellValue)) {
authTransaction.setHosts(Integer.valueOf(cellValue));
}
} else if (cell.getCellType() == Cell.CELL_TYPE_STRING && StringUtils.isNotBlank(cell.getStringCellValue())) {
String cellValue = cell.getStringCellValue().trim();
if (DataUtils.isInteger(cellValue)) {
authTransaction.setHosts(Integer.valueOf(cellValue));
}
}
}
break;*/
case 22:// 主机制造厂->航区
if (cell != null && cell.getCellType() == Cell.CELL_TYPE_STRING && StringUtils.isNotBlank(cell.getStringCellValue())) {
String cellValue = cell.getStringCellValue().trim();
authTransaction.setNavigationArea(cellValue);
}
break;
/*if (cell != null && cell.getCellType() == Cell.CELL_TYPE_STRING && StringUtils.isNotBlank(cell.getStringCellValue())) {
String cellValue = cell.getStringCellValue().trim();
authTransaction.setHostFactory(cellValue);
}
break;*/
case 23:// 副机型号->总长
if (cell != null) {
if (cell.getCellType() == Cell.CELL_TYPE_NUMERIC) {
authTransaction.setShipLength(cell.getNumericCellValue());
} else if (cell.getCellType() == Cell.CELL_TYPE_STRING && StringUtils.isNotBlank(cell.getStringCellValue())) {
String cellValue = cell.getStringCellValue().trim();
if (DataUtils.isNumeric(cellValue)) {
authTransaction.setShipLength(Double.valueOf(cellValue));
}
}
}
break;
/*if (cell != null && cell.getCellType() == Cell.CELL_TYPE_STRING && StringUtils.isNotBlank(cell.getStringCellValue())) {
String cellValue = cell.getStringCellValue().trim();
authTransaction.setSideModel(cellValue);
}
break;*/
case 24:// 副机台数->型宽.
if (cell != null) {
if (cell.getCellType() == Cell.CELL_TYPE_NUMERIC) {
authTransaction.setShipWidth(cell.getNumericCellValue());
} else if (cell.getCellType() == Cell.CELL_TYPE_STRING && StringUtils.isNotBlank(cell.getStringCellValue())) {
String cellValue = cell.getStringCellValue().trim();
if (DataUtils.isNumeric(cellValue)) {
authTransaction.setShipWidth(Double.valueOf(cellValue));
}
}
}
break;
/*if (cell != null) {
if (cell.getCellType() == Cell.CELL_TYPE_NUMERIC) {
String cellValue = df.format(cell.getNumericCellValue());
if (DataUtils.isInteger(cellValue)) {
authTransaction.setSides(Integer.valueOf(cellValue));
}
} else if (cell.getCellType() == Cell.CELL_TYPE_STRING && StringUtils.isNotBlank(cell.getStringCellValue())) {
String cellValue = cell.getStringCellValue().trim();
if (DataUtils.isInteger(cellValue)) {
authTransaction.setSides(Integer.valueOf(cellValue));
}
}
}
break;*/
case 25:// 副机制造厂->型深
if (cell != null) {
if (cell.getCellType() == Cell.CELL_TYPE_NUMERIC) {
authTransaction.setShipHeight(cell.getNumericCellValue());
} else if (cell.getCellType() == Cell.CELL_TYPE_STRING && StringUtils.isNotBlank(cell.getStringCellValue())) {
String cellValue = cell.getStringCellValue().trim();
if (DataUtils.isNumeric(cellValue)) {
authTransaction.setShipHeight(Double.valueOf(cellValue));
}
}
}
/*if (cell != null && cell.getCellType() == Cell.CELL_TYPE_STRING && StringUtils.isNotBlank(cell.getStringCellValue())) {
String cellValue = cell.getStringCellValue().trim();
authTransaction.setSideFactory(cellValue);
}
break;*/
case 26:// 成交价格->主机型号
if (cell != null && cell.getCellType() == Cell.CELL_TYPE_STRING && StringUtils.isNotBlank(cell.getStringCellValue())) {
String cellValue = cell.getStringCellValue().trim();
authTransaction.setHostModel(cellValue);
}
break;
/*if (cell != null) {
if (cell.getCellType() == Cell.CELL_TYPE_NUMERIC) {
authTransaction.setPrice(cell.getNumericCellValue());
} else if (cell.getCellType() == Cell.CELL_TYPE_STRING && StringUtils.isNotBlank(cell.getStringCellValue())) {
String cellValue = cell.getStringCellValue().trim();
if (DataUtils.isNumeric(cellValue)) {
authTransaction.setPrice(Double.valueOf(cellValue));
}
}
}
break;*/
case 27:// 成交日期->主机功率
if (cell != null) {
if (cell.getCellType() == Cell.CELL_TYPE_NUMERIC) {
authTransaction.setHostPower(cell.getNumericCellValue());
} else if (cell.getCellType() == Cell.CELL_TYPE_STRING && StringUtils.isNotBlank(cell.getStringCellValue())) {
String cellValue = cell.getStringCellValue().trim();
if (DataUtils.isNumeric(cellValue)) {
authTransaction.setHostPower(Double.valueOf(cellValue));
}
}
}
break;
/* if (cell != null && HSSFDateUtil.isCellDateFormatted(cell)) {
authTransaction.setTradeDate(cell.getDateCellValue());
}
break;*/
case 28:// 鉴证费->主机转速
if (cell != null) {
if (cell.getCellType() == Cell.CELL_TYPE_NUMERIC) {
authTransaction.setHostSpeed(cell.getNumericCellValue());
} else if (cell.getCellType() == Cell.CELL_TYPE_STRING && StringUtils.isNotBlank(cell.getStringCellValue())) {
String cellValue = cell.getStringCellValue().trim();
if (DataUtils.isNumeric(cellValue)) {
authTransaction.setHostSpeed(Double.valueOf(cellValue));
}
}
}
break;
/*if (cell != null) {
if (cell.getCellType() == Cell.CELL_TYPE_NUMERIC) {
authTransaction.setAuthCharge(cell.getNumericCellValue());
} else if (cell.getCellType() == Cell.CELL_TYPE_STRING && StringUtils.isNotBlank(cell.getStringCellValue())) {
String cellValue = cell.getStringCellValue().trim();
if (DataUtils.isNumeric(cellValue)) {
authTransaction.setAuthCharge(Double.valueOf(cellValue));
}
}
}
break;*/
case 29:// 鉴证日期->主机台数
if (cell != null) {
if (cell.getCellType() == Cell.CELL_TYPE_NUMERIC) {
String cellValue = df.format(cell.getNumericCellValue());
if (DataUtils.isInteger(cellValue)) {
authTransaction.setHosts(Integer.valueOf(cellValue));
}
} else if (cell.getCellType() == Cell.CELL_TYPE_STRING && StringUtils.isNotBlank(cell.getStringCellValue())) {
String cellValue = cell.getStringCellValue().trim();
if (DataUtils.isInteger(cellValue)) {
authTransaction.setHosts(Integer.valueOf(cellValue));
}
}
}
break;
/*if (cell != null && HSSFDateUtil.isCellDateFormatted(cell)) {
authTransaction.setAuthDate(cell.getDateCellValue());
}
break;*/
case 30:// 卖方->主机制造厂
if (cell != null && cell.getCellType() == Cell.CELL_TYPE_STRING && StringUtils.isNotBlank(cell.getStringCellValue())) {
String cellValue = cell.getStringCellValue().trim();
authTransaction.setHostFactory(cellValue);
}
break;
/*if (cell != null && cell.getCellType() == Cell.CELL_TYPE_STRING && StringUtils.isNotBlank(cell.getStringCellValue())) {
String cellValue = cell.getStringCellValue().trim();
authTransaction.setSeller(cellValue);
}
break;*/
case 31:// 卖方所在地->副机型号
if (cell != null && cell.getCellType() == Cell.CELL_TYPE_STRING && StringUtils.isNotBlank(cell.getStringCellValue())) {
String cellValue = cell.getStringCellValue().trim();
authTransaction.setSideModel(cellValue);
}
break;
/*if (cell != null && cell.getCellType() == Cell.CELL_TYPE_STRING && StringUtils.isNotBlank(cell.getStringCellValue())) {
String cellValue = cell.getStringCellValue().trim();
authTransaction.setSellerLocation(cellValue);
}
break;*/
case 32:// 买方->副机台数
if (cell != null) {
if (cell.getCellType() == Cell.CELL_TYPE_NUMERIC) {
String cellValue = df.format(cell.getNumericCellValue());
if (DataUtils.isInteger(cellValue)) {
authTransaction.setSides(Integer.valueOf(cellValue));
}
} else if (cell.getCellType() == Cell.CELL_TYPE_STRING && StringUtils.isNotBlank(cell.getStringCellValue())) {
String cellValue = cell.getStringCellValue().trim();
if (DataUtils.isInteger(cellValue)) {
authTransaction.setSides(Integer.valueOf(cellValue));
}
}
}
break;
/*if (cell != null && cell.getCellType() == Cell.CELL_TYPE_STRING && StringUtils.isNotBlank(cell.getStringCellValue())) {
String cellValue = cell.getStringCellValue().trim();
authTransaction.setBuyer(cellValue);
}
break;*/
case 33:// 买方所在地->最近一次船检时间
if (cell != null && cell.getCellType() == Cell.CELL_TYPE_STRING && StringUtils.isNotBlank(cell.getStringCellValue())) {
String cellValue = cell.getStringCellValue().trim();
authTransaction.setRecentlyCheckTime(cellValue);
}
break;
case 34:// 下一次船检时间
if (cell != null && cell.getCellType() == Cell.CELL_TYPE_STRING && StringUtils.isNotBlank(cell.getStringCellValue())) {
String cellValue = cell.getStringCellValue().trim();
authTransaction.setNextCheckTime(cellValue);
}
break;
/*if (cell != null && cell.getCellType() == Cell.CELL_TYPE_STRING && StringUtils.isNotBlank(cell.getStringCellValue())) {
String cellValue = cell.getStringCellValue().trim();
authTransaction.setBuyerLocation(cellValue);
}
break;*/
case 35:// 卖方所在地->保险
if (cell != null && cell.getCellType() == Cell.CELL_TYPE_STRING && StringUtils.isNotBlank(cell.getStringCellValue())) {
String cellValue = cell.getStringCellValue().trim();
authTransaction.setBuySafe(cellValue);
}
break;
case 36:// 下一次船检时间
if (cell != null && HSSFDateUtil.isCellDateFormatted(cell)) {
authTransaction.setBuyTime(cell.getDateCellValue());
}
break;
case 38://卖方
if (cell != null && cell.getCellType() == Cell.CELL_TYPE_STRING && StringUtils.isNotBlank(cell.getStringCellValue())) {
String cellValue = cell.getStringCellValue().trim();
authTransaction.setSeller(cellValue);
}
break;
case 39://卖方所在地
if (cell != null && cell.getCellType() == Cell.CELL_TYPE_STRING && StringUtils.isNotBlank(cell.getStringCellValue())) {
String cellValue = cell.getStringCellValue().trim();
authTransaction.setSellerLocation(cellValue);
}
break;
case 40://卖方联系方式
if (cell != null && cell.getCellType() == Cell.CELL_TYPE_STRING && StringUtils.isNotBlank(cell.getStringCellValue())) {
String cellValue = cell.getStringCellValue().trim();
authTransaction.setSellPhone(cellValue);
}
break;
case 41://买方
if (cell != null && cell.getCellType() == Cell.CELL_TYPE_STRING && StringUtils.isNotBlank(cell.getStringCellValue())) {
String cellValue = cell.getStringCellValue().trim();
authTransaction.setBuyer(cellValue);
}
break;
case 42://买方所在地
if (cell != null && cell.getCellType() == Cell.CELL_TYPE_STRING && StringUtils.isNotBlank(cell.getStringCellValue())) {
String cellValue = cell.getStringCellValue().trim();
authTransaction.setBuyerLocation(cellValue);
}
break;
case 43://买方联系方式
if (cell != null && cell.getCellType() == Cell.CELL_TYPE_STRING && StringUtils.isNotBlank(cell.getStringCellValue())) {
String cellValue = cell.getStringCellValue().trim();
authTransaction.setBuyPhone(cellValue);
}
break;
case 44://经纪人
if (cell != null && cell.getCellType() == Cell.CELL_TYPE_STRING && StringUtils.isNotBlank(cell.getStringCellValue())) {
String cellValue = cell.getStringCellValue().trim();
authTransaction.setAgent(cellValue);
}
break;
case 45://经纪人联系方式
if (cell != null && cell.getCellType() == Cell.CELL_TYPE_STRING && StringUtils.isNotBlank(cell.getStringCellValue())) {
String cellValue = cell.getStringCellValue().trim();
authTransaction.setAgentPhone(cellValue);
}
break;
case 49://备注
if (cell != null && cell.getCellType() == Cell.CELL_TYPE_STRING && StringUtils.isNotBlank(cell.getStringCellValue())) {
String cellValue = cell.getStringCellValue().trim();
authTransaction.setBref(cellValue);
}
break;
default:
break;
}
if(flag == 0)
continue;
else if(flag == 1)
break;
}
authTransaction.setStatus(AuditStatus.NEW.getValue());
if(StringUtils.isNotEmpty(authTransaction.getAuthApplicationNo())){
tempResult.add(authTransaction);
}
} catch (Exception e) {
e.printStackTrace();
}
}
}
return tempResult;
}
});
if (CollectionUtils.isNotEmpty(parseResult)) {
for (AuthTransaction obj : parseResult) {
this.saveEntity(obj);
}
} else {
throw new Exception("导入数据为空");
}
}
excel解析二维数组结构的excel的更多相关文章
- PHP导出excel文件,第二步先实现自写二维数组加入模板excel文件后导出
今天主要研究数据加入EXCEL并导出的问题,先不从数据库提取数据导出,自己先写一个二维数组,然后遍历二维数组写入excel模板中导出,首先根据模板excel的内容书写对应的二维数组 $arr=arra ...
- 将一,二维数组转化为Excel格式
首先,我们来看一下一维数组的, 其代码可以如下: import numpy as np import pandas as pd x = pd.Series([1, 3, 5, np.nan]) pri ...
- Highcharts使用二维数组生成图表
Highcharts使用二维数组生成图表 二维数组是更为灵活的一种数据存储方式.在Highcharts中.能够使用配置项column和rows二维数组.对于使用columns构建的二维数组,Highc ...
- Java读取excel指定sheet中的各行数据,存入二维数组,包括首行,并打印
1. 读取 //读取excel指定sheet中的各行数据,存入二维数组,包括首行 public static String[][] getSheetData(XSSFSheet sheet) thro ...
- Excel 二维数组(数据块)旋转/翻转技巧
Excel 二维数组(数据块)旋转/翻转技巧 原创 2017-12-30 久石六 久石六 工作中遇到个问题,需要将Excel中的数据块或者说二维数组向右旋转90度,才能再加工处理.当然,不是旋转文本方 ...
- 使用POI对excel进行操作生成二维数组
import java.io.File; import java.io.FileInputStream; import java.io.FileNotFoundException; import ja ...
- php上传excle文件,csv文件解析为二维数组
解析上传的CSV文件不是什么难事,直接读取转成你想要的数组样子就OK了. public function putStoreStockIn ($filePath = '') { $file = fope ...
- jquery解析php通过ajax传过来的json二维数组对象
ajax获得php传过来的json二维数组对象,jquery解析 php代码: <?php $news = array( '武汉'=>array(1,2,3), '广州'=>arra ...
- C语言一维数组、二维数组、结构体的初始化
C语言数组的初始化表示方法 一.C语言一维数组初始化: (1)在定义数组时对数组元素赋以初值.如: static int a[10]={0,1,2,3,4,5,6,7,8,9}; 经过上面的定义和初始 ...
随机推荐
- centos6.5为tengine安装php 5.6支持
1.到php官网下载最新的php版本 http://php.net/ 我下载的是php-5.6.28.tar.bz2 2.编译安装 2.1安装依赖 2.1.1 解决libxml2和xml2-confi ...
- ionic 常见问题
1.Couldn't find ionic.config.json file. ? a.在C:\Users\(Username)\.ionic目录下有ionic.config这个文件 添加后缀名jso ...
- ecmobile-ios笔记
col或者row里的v-align:bottom会导致里面所有的元素都到bottom,如果有一个元素还好,多个元素,第一个会到底.
- Sqlite小数作差,会减不尽?
select 6307.65-5922.68 from CW_ZWMX 以上语句,在设Navigate中执行的结果是:384.969999999999 不解!!!
- 双系统 fedora 恢复引导
因为硬盘坏了,所以买了个固态的用用. 先装windows,再装fedora及常用必备的驱动软件装上. 快要完成了心情都挺好,可是在一次关机时window7关机很慢一直在删索引,我嫌时间太长,直接按电源 ...
- 优先级反转实验,使用信号量实现【RT-Thread学习笔记 5】
RTOS中很经典的问题.就是在使用共享资源的时候,优先级低的进程在优先级高的进程之前执行的问题.这里模拟这种情况. 下面的实验模拟了优先级反转的情况: 先定义三个线程: //优先级反转实验 rt_se ...
- 深入理解Bootstrap笔记
框架介绍 1.框架简介 2.CSS基本语法 3.JavaScript基本语法 4.Bootstrap整体架构 5.12栅格系统 6.CSS组件架构设计思想 7.JavaScript插件架构 CSS布局 ...
- XUtils 3 使用
源代码:https://github.com/wyouflf/xUtils 基本使用:http://blog.csdn.net/abc6368765/article/details/50699334 ...
- 2016年第七届蓝桥杯C/C++程序设计本科B组决赛
2.答案300 刁丝卫代码,比赛时long long写成int,结果成了263...一等擦肩而过... #include <iostream> #include <fstream&g ...
- asp.net中web.config配置节点大全详解
最近网上找了一些关于Web.config配置节点的文章,发现很多都写的都比较零散,而且很少有说明各个配置节点的作用和用法.搜索了一下发现有一篇写的不错,这里引用一下 原文地址 http://www.c ...