这个问题折腾了我半天,我的导入和导出分别用了连个poi包,这两个包冲突,删掉其中一个,则另一个功能就不能使用,很纠结,试了很多方法,但是我的import的工具的版本还不能换,版本必须一致,所以我决定,删除一个版本,我的两个版本分别位poi-3.8和poi2.2,因为poi-2.2中没有Cell这个类,所以我删除poi3.8我的action就会报错,我索性删除了poi3.8看看有没有别的方法,把Cell删除
HSSFRow row = sheet.getRow(i);
// 获取一行每一列的数据
HSSFCell userCodeCell = row.getCell(0);
HSSFCell userNameCell = row.getCell(1);
row.getCell(2).setCellType(Cell.CELL_TYPE_STRING);
HSSFCell passWordCell = row.getCell(2);
HSSFCell userDescriptionCell = row.getCell(3);
HSSFCell userStateCell = row.getCell(4);
HSSFCell superPopedomFlagCell = row.getCell(5);
HSSFCell validStartDateCell = row.getCell(6);
HSSFCell validEndDateCell = row.getCell(7);
// HSSFCell pwdFlagDateCell=row.getCell(8);
HSSFCell userEmailCell = row.getCell(8);
String userCode = userCodeCell.getRichStringCellValue()
.getString();
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
String validStartDate = new java.text.SimpleDateFormat(
"yyyy-MM-dd").format(validStartDateCell
.getDateCellValue());
String userName = userNameCell.getRichStringCellValue()
.getString();
String passWord = passWordCell.getRichStringCellValue()
.getString();
String userDescription = userDescriptionCell
.getRichStringCellValue().getString();
String userState = userStateCell.getRichStringCellValue()
.getString();
String superPopedomFlag = superPopedomFlagCell
.getRichStringCellValue().getString();
String validEndDate = new java.text.SimpleDateFormat(
"yyyy-MM-dd").format(validEndDateCell
.getDateCellValue());
System.out.println(userCode + "--" + userName + "--"
+ passWord + "--" + userState + "--"
+ superPopedomFlag + "--" + validEndDate);
String userEmail = userEmailCell.getRichStringCellValue()
.getString();
这个是删除之前的方法,修改之后====
HSSFRow row = sheet.getRow(i);
// 获取一行每一列的数据
HSSFCell planNameCell = row.getCell((short) 0);
HSSFCell planPersonCell = row.getCell((short) 1);
HSSFCell tierCodeCell = row.getCell((short) 2);
HSSFCell carCodeCell = row.getCell((short) 3);
HSSFCell planAddressCell = row.getCell((short) 4);
HSSFCell planLevelCell = row.getCell((short) 5);
HSSFCell planTimeCell = row.getCell((short) 6);
// HSSFCell pwdFlagDateCell=row.getCell(8);
HSSFCell planPictureCell = row.getCell((short) 7);
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
String planTime = new java.text.SimpleDateFormat(
"yyyy-MM-dd").format(planTimeCell
.getDateCellValue());
String planName = planNameCell
.getStringCellValue();
String planPerson = planPersonCell
.getStringCellValue();
String tierCode = tierCodeCell
.getStringCellValue();
String carCode = carCodeCell
.getStringCellValue();
String planAddress = planAddressCell
.getStringCellValue();
String planLevel = planLevelCell
.getStringCellValue();
String planPicture = planPictureCell
.getStringCellValue();
File fi = new File(planPicture);
String fileName= planPicture.substring(planPicture.lastIndexOf("\\")+1);
if(fi.exists()){
fi.mkdirs();
}
把Cell去掉了,换了另一种方式取值,可能新旧版本不兼容,新版本有新的类加入所以只能这样,好纠结,特写此文,以缅情怀