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 "";
}