private String initial() throws BiffException, IOException {
Workbook book = Workbook.getWorkbook(new File(file));
Sheet[] sheets = book.getSheets();
for (Sheet sheet : sheets) {
if("Sheet1".equalsIgnoreCase(sheet.getName().trim())) {
for(int j=2; j<sheet.getRows(); j++) {
Cell cell = sheet.getCell(0, j);
String planCode = cell.getContents().trim();
String tranche = sheet.getCell(1, j).getContents().trim();
String region = sheet.getCell(2, j).getContents().trim();
String channel = sheet.getCell(3, j).getContents().trim();
String branchCode = sheet.getCell(4, j).getContents().trim();
String effectiveDateStr = sheet.getCell(6, j).getContents().trim();
Calendar startDate = Calendar.getInstance();
startDate.set(Calendar.YEAR, Integer.parseInt(effectiveDateStr.substring(0, 4)));
startDate.set(Calendar.MONTH, Integer.parseInt(effectiveDateStr.substring(4, 5)));
startDate.set(Calendar.DAY_OF_MONTH, Integer.parseInt(effectiveDateStr.substring(6, 7)));
startDate.set(Calendar.MINUTE, 0);
startDate.set(Calendar.SECOND, 0);
startDate.set(Calendar.HOUR_OF_DAY, 0);
String expiryDateStr = sheet.getCell(7, j).getContents().trim();
Calendar endDate = Calendar.getInstance();
endDate.set(Calendar.YEAR, Integer.parseInt(expiryDateStr.substring(0, 4)));
endDate.set(Calendar.MONTH, Integer.parseInt(expiryDateStr.substring(4, 5)));
endDate.set(Calendar.DAY_OF_MONTH, Integer.parseInt(expiryDateStr.substring(6, 7)));
endDate.set(Calendar.MINUTE, 0);
endDate.set(Calendar.SECOND, 0);
endDate.set(Calendar.HOUR_OF_DAY, 0);
// if(products.size() > 0) {
// Product lastProduct = products.get(products.size() - 1);
// if(planCode.equals(lastProduct.getPlanCode())) {
// System.out.println("已存在的产品");
// }
// }
Product product = new Product();
product.setPlanCode(planCode);
product.setBranchCode(branchCode);
product.setChannel(channel);
product.setRegion(region);
product.setTranche(tranche);
product.setEffectiveDate(startDate.getTime());
product.setExpiryDate(endDate.getTime());
products.add(product);
}
}
}
book.close();
return "";
}Excel 获取数据 / jxl-2.6.10.jar | log4j-1.2.14.jar
原创
©著作权归作者所有:来自51CTO博客作者nethub的原创作品,请联系作者获取转载授权,否则将追究法律责任
上一篇:基于Spring访问REST服务
下一篇:CSS块级元素和行内元素
提问和评论都可以,用心的回复会被更多人看到
评论
发布评论
相关文章
-
java接收小程序发送的protobuf消息
/接收数据,对ProtoBu数据进行反序列化,返回的是ChargingCmd对象,ChargingCmdProtobuf.ChargingCmd是我们定义的消息类型,//添加消息转换处理器,将WebSocketFrame消息转换为ProtoBuf二进制类型的消息。//处理二进制消息,protobuf消息以二进制形式传输的。//添加到list中,交给下一个handler处理。//发送数据,对ProtoBu数据进行序列化。//retain引用计数,防止释放。//发送数据,ProtoBu序列化。
#netty #protobuf #websocket HTTP .net
















