public String execute() throws Exception {
//String filename="C:\\Users\\Administrator\\Desktop\\副本tempexcel.xls";
//FileInputStream file=new FileInputStream(filename);
//System.out.println(file);
HttpServletResponse response=null;
response=ServletActionContext.getResponse();
response.setContentType("text/html;charset=UTF-8");
response.setCharacterEncoding("UTF-8");
PrintWriter out = response.getWriter();
POIFSFileSystem fs=new POIFSFileSystem(new FileInputStream(stuUploadFile));
HSSFWorkbook wb=new HSSFWorkbook(fs);
HSSFSheet hssfSheet=wb.getSheetAt(0);
if(hssfSheet!=null){
for(int rowNum=1;rowNum<=hssfSheet.getLastRowNum();rowNum++){
HSSFRow hssfRow=hssfSheet.getRow(rowNum);
if(hssfRow==null){
continue;
}
StudentBean user=new StudentBean();
String a=ExcelUtil.formatCell(hssfRow.getCell(0));
String b=ExcelUtil.formatCell(hssfRow.getCell(1));
String c=ExcelUtil.formatCell(hssfRow.getCell(2));
String d=ExcelUtil.formatCell(hssfRow.getCell(3));
String e=ExcelUtil.formatCell(hssfRow.getCell(4));
String f=ExcelUtil.formatCell(hssfRow.getCell(5));
String g=ExcelUtil.formatCell(hssfRow.getCell(5));
user.setStudent_DomitoryID(Integer.parseInt(a.substring(0, a.indexOf("."))));
user.setStudent_Username(b.substring(0, b.indexOf(".")));
user.setStudent_Password(c.substring(0, c.indexOf(".")));
user.setStudent_Name(d);
user.setStudent_Sex(e);
user.setStudent_Class(f);
user.setStudent_State(g);
new StudentDao().Add(user);
}
}
//String filename="C:\\Users\\Administrator\\Desktop\\副本tempexcel.xls";
//FileInputStream file=new FileInputStream(filename);
//System.out.println(file);
HttpServletResponse response=null;
response=ServletActionContext.getResponse();
response.setContentType("text/html;charset=UTF-8");
response.setCharacterEncoding("UTF-8");
PrintWriter out = response.getWriter();
POIFSFileSystem fs=new POIFSFileSystem(new FileInputStream(stuUploadFile));
HSSFWorkbook wb=new HSSFWorkbook(fs);
HSSFSheet hssfSheet=wb.getSheetAt(0);
if(hssfSheet!=null){
for(int rowNum=1;rowNum<=hssfSheet.getLastRowNum();rowNum++){
HSSFRow hssfRow=hssfSheet.getRow(rowNum);
if(hssfRow==null){
continue;
}
StudentBean user=new StudentBean();
String a=ExcelUtil.formatCell(hssfRow.getCell(0));
String b=ExcelUtil.formatCell(hssfRow.getCell(1));
String c=ExcelUtil.formatCell(hssfRow.getCell(2));
String d=ExcelUtil.formatCell(hssfRow.getCell(3));
String e=ExcelUtil.formatCell(hssfRow.getCell(4));
String f=ExcelUtil.formatCell(hssfRow.getCell(5));
String g=ExcelUtil.formatCell(hssfRow.getCell(5));
user.setStudent_DomitoryID(Integer.parseInt(a.substring(0, a.indexOf("."))));
user.setStudent_Username(b.substring(0, b.indexOf(".")));
user.setStudent_Password(c.substring(0, c.indexOf(".")));
user.setStudent_Name(d);
user.setStudent_Sex(e);
user.setStudent_Class(f);
user.setStudent_State(g);
new StudentDao().Add(user);
}
}