public String doSend(){
ArrayList <EmpEntity> list=new ArrayList<EmpEntity>();
if(!"".equals(path)){
try {
System.out.println(path);
//获取输入流
InputStream input=new FileInputStream(path);
//获取工作簿对象
HSSFWorkbook wb = new HSSFWorkbook(input);
//获取工作表
HSSFSheet sheet=wb.getSheetAt(0);
//获取工作表中的数据行数
int count=sheet.getLastRowNum();
//循环遍历数据表
for(int i=1;i<=count;i++){
//获取每行
HSSFRow row=sheet.getRow(i);
String id=row.getCell((short)0).getStringCellValue();
String name=row.getCell((short)1).getStringCellValue();
String sex=row.getCell((short)2).getStringCellValue();
String deptName=row.getCell((short)3).getStringCellValue();
String post=row.getCell((short)4).getStringCellValue();
double balance=row.getCell((short)5).getNumericCellValue();
int deptid=0;
if("研发部".equals(deptName))
deptid=21;
else if("市场部".equals(deptName))
deptid=22;
else
deptid=23;
//转换拼音码
String convert = "";
for (int j = 0; j < name.length(); j++) {
char word = name.charAt(j);
// 提取汉字的首字母
String[] pinyinArray = PinyinHelper.toHanyuPinyinStringArray(word);
if (pinyinArray != null) {
convert += pinyinArray[0].charAt(0);
} else {
convert += word;
}
}
EmpEntity emp=new EmpEntity(id,name,sex,post,balance,deptid,convert);
list.add(emp);
}
ServletActionContext.getRequest().getSession().setAttribute("empList",list);
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
return "index";
}
ArrayList <EmpEntity> list=new ArrayList<EmpEntity>();
if(!"".equals(path)){
try {
System.out.println(path);
//获取输入流
InputStream input=new FileInputStream(path);
//获取工作簿对象
HSSFWorkbook wb = new HSSFWorkbook(input);
//获取工作表
HSSFSheet sheet=wb.getSheetAt(0);
//获取工作表中的数据行数
int count=sheet.getLastRowNum();
//循环遍历数据表
for(int i=1;i<=count;i++){
//获取每行
HSSFRow row=sheet.getRow(i);
String id=row.getCell((short)0).getStringCellValue();
String name=row.getCell((short)1).getStringCellValue();
String sex=row.getCell((short)2).getStringCellValue();
String deptName=row.getCell((short)3).getStringCellValue();
String post=row.getCell((short)4).getStringCellValue();
double balance=row.getCell((short)5).getNumericCellValue();
int deptid=0;
if("研发部".equals(deptName))
deptid=21;
else if("市场部".equals(deptName))
deptid=22;
else
deptid=23;
//转换拼音码
String convert = "";
for (int j = 0; j < name.length(); j++) {
char word = name.charAt(j);
// 提取汉字的首字母
String[] pinyinArray = PinyinHelper.toHanyuPinyinStringArray(word);
if (pinyinArray != null) {
convert += pinyinArray[0].charAt(0);
} else {
convert += word;
}
}
EmpEntity emp=new EmpEntity(id,name,sex,post,balance,deptid,convert);
list.add(emp);
}
ServletActionContext.getRequest().getSession().setAttribute("empList",list);
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
return "index";
}