package com.wy.tool;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.List;
import org.apache.poi.hssf.usermodel.HSSFCell;
import org.apache.poi.hssf.usermodel.HSSFRow;
import org.apache.poi.hssf.usermodel.HSSFSheet;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.xssf.usermodel.XSSFCell;
import org.apache.poi.xssf.usermodel.XSSFRow;
import org.apache.poi.xssf.usermodel.XSSFSheet;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import com.wy.form.EmployeeForm;
public class ReadExcel {
/**
* read the Excel file
* @param path the path of the Excel file
* @return
* @throws IOException
*/
public List<EmployeeForm> readExcel(String path) throws IOException {
if (path == null || Common.EMPTY.equals(path)) {
return null;
} else {
String postfix = getPostfix(path);
if (!Common.EMPTY.equals(postfix)) {
if (Common.OFFICE_EXCEL_2003_POSTFIX.equals(postfix)) {
return readXls(path);
} else if (Common.OFFICE_EXCEL_2010_POSTFIX.equals(postfix)) {
return readXlsx(path);
}
} else {
System.out.println(path + Common.NOT_EXCEL_FILE);
}
}
return null;
}
public static String getPostfix(String path) {
if (path == null || Common.EMPTY.equals(path.trim())) {
return Common.EMPTY;
}
if (path.contains(Common.POINT)) {
return path.substring(path.lastIndexOf(Common.POINT) + 1, path.length());
}
return Common.EMPTY;
}
public List<EmployeeForm> readXlsx(String path) throws IOException {
System.out.println(Common.PROCESSING + path);
InputStream is = new FileInputStream(path);
XSSFWorkbook xssfWorkbook = new XSSFWorkbook(is);
EmployeeForm student = null;
List<EmployeeForm> list = new ArrayList<EmployeeForm>();
// Read the Sheet
for (int numSheet = 0; numSheet < xssfWorkbook.getNumberOfSheets(); numSheet++) {
XSSFSheet xssfSheet = xssfWorkbook.getSheetAt(numSheet);
if (xssfSheet == null) {
continue;
}
// Read the Row
for (int rowNum = 1; rowNum <= xssfSheet.getLastRowNum(); rowNum++) {
XSSFRow xssfRow = xssfSheet.getRow(rowNum);
if (xssfRow != null) {
student= new EmployeeForm();
XSSFCell id = xssfRow.getCell(0);
XSSFCell sNO = xssfRow.getCell(1);
XSSFCell name = xssfRow.getCell(2);
XSSFCell sex = xssfRow.getCell(3);
XSSFCell age = xssfRow.getCell(4);
XSSFCell IDcard = xssfRow.getCell(5);
XSSFCell born = xssfRow.getCell(6);
XSSFCell nation = xssfRow.getCell(7);
XSSFCell marriage = xssfRow.getCell(8);
XSSFCell visage = xssfRow.getCell(9);
XSSFCell aHome = xssfRow.getCell(10);
XSSFCell tel = xssfRow.getCell(11);
XSSFCell address = xssfRow.getCell(12);
XSSFCell afterSchool = xssfRow.getCell(13);
XSSFCell speciality = xssfRow.getCell(14);
XSSFCell culture = xssfRow.getCell(15);
XSSFCell startime = xssfRow.getCell(16);
XSSFCell departmentId = xssfRow.getCell(17);
XSSFCell typework = xssfRow.getCell(18);
XSSFCell creatime = xssfRow.getCell(19);
XSSFCell createName = xssfRow.getCell(20);
XSSFCell mbz = xssfRow.getCell(21);
student.setId(getValue(id));
student.setEm_serialNumber(getValue(sNO));
student.setEm_name(getValue(name));
student.setEm_sex(getValue(sex));
student.setEm_age(getValue(age));
student.setEm_IDCard(getValue(IDcard));
student.setEm_born(getValue(born));
student.setEm_nation(getValue(nation));
student.setEm_marriage(getValue(marriage));
student.setEm_visage(getValue(visage));
student.setEm_ancestralHome(getValue(aHome));
student.setEm_tel(getValue(tel));
student.setEm_address(getValue(address));
student.setEm_afterschool(getValue(afterSchool));
student.setEm_speciality(getValue(speciality));
student.setEm_culture(getValue(culture));
student.setEm_startime(getValue(startime));
student.setEm_departmentId(getValue(departmentId));
student.setEm_typework(getValue(typework));
student.setEm_creatime(getValue(creatime));
student.setEm_bz(getValue(mbz));
list.add(student);
}
}
}
return list;
}
/**
* Read the Excel 2003-2007
* @param path the path of the Excel
* @return
* @throws IOException
*/
public List<EmployeeForm> readXls(String path) throws IOException {
System.out.println(Common.PROCESSING + path);
InputStream is = new FileInputStream(path);
HSSFWorkbook hssfWorkbook = new HSSFWorkbook(is);
EmployeeForm student = null;
List<EmployeeForm> list = new ArrayList<EmployeeForm>();
// Read the Sheet
for (int numSheet = 0; numSheet < hssfWorkbook.getNumberOfSheets(); numSheet++) {
HSSFSheet hssfSheet = hssfWorkbook.getSheetAt(numSheet);
if (hssfSheet == null) {
continue;
}
// Read the Row
for (int rowNum = 1; rowNum <= hssfSheet.getLastRowNum(); rowNum++) {
HSSFRow hssfRow = hssfSheet.getRow(rowNum);
if (hssfRow != null) {
student = new EmployeeForm();
HSSFCell id = hssfRow.getCell(0);
HSSFCell sNO = hssfRow.getCell(1);
HSSFCell name = hssfRow.getCell(2);
HSSFCell sex = hssfRow.getCell(3);
HSSFCell age = hssfRow.getCell(4);
HSSFCell IDcard = hssfRow.getCell(5);
HSSFCell born = hssfRow.getCell(6);
HSSFCell nation = hssfRow.getCell(7);
HSSFCell marriage = hssfRow.getCell(8);
HSSFCell visage = hssfRow.getCell(9);
HSSFCell aHome = hssfRow.getCell(10);
HSSFCell tel = hssfRow.getCell(11);
HSSFCell address = hssfRow.getCell(12);
HSSFCell afterSchool = hssfRow.getCell(13);
HSSFCell speciality = hssfRow.getCell(14);
HSSFCell culture = hssfRow.getCell(15);
HSSFCell startime = hssfRow.getCell(16);
HSSFCell departmentId = hssfRow.getCell(17);
HSSFCell typework = hssfRow.getCell(18);
HSSFCell creatime = hssfRow.getCell(19);
HSSFCell createName = hssfRow.getCell(20);
HSSFCell bz = hssfRow.getCell(21);
student.setId(getValue(id));
student.setEm_serialNumber(getValue(sNO));
student.setEm_name(getValue(name));
student.setEm_sex(getValue(sex));
student.setEm_age(getValue(age));
student.se
没有合适的资源?快使用搜索试试~ 我知道了~
java web 企业人力资源管理系统
共267个文件
jar:75个
jsp:38个
java:27个
4星 · 超过85%的资源 需积分: 50 97 下载量 113 浏览量
2017-07-31
12:10:15
上传
评论 15
收藏 43.94MB ZIP 举报
温馨提示
excel表批量导入数据库,批量删除,员工管理,部门管理,薪资管理,培训管理,招聘管理(连接数据库要mysql执行sql文件,改配置文件,换成自己的数据库账号和密码)
资源推荐
资源详情
资源评论
收起资源包目录
java web 企业人力资源管理系统 (267个子文件)
EmployeeAction.class 8KB
ReadExcel.class 7KB
EmployeeForm.class 5KB
StuService.class 5KB
CakeServlet.class 5KB
testServlet.class 4KB
ExportExcel.class 4KB
ManagerAction.class 4KB
PayAction.class 4KB
MyPagination.class 4KB
InviteJobAction.class 3KB
InviteJobForm.class 3KB
CjAction.class 3KB
DepartmentAction.class 3KB
DBhepler.class 3KB
TrainAction.class 3KB
PayForm.class 3KB
Tools.class 3KB
TrainForm.class 2KB
ObjectDao.class 2KB
CjForm.class 2KB
DepartmentForm.class 1KB
ManagerForm.class 1KB
GetSystemTime.class 1KB
SelfRequestProcessor.class 967B
GetAutoNumber.class 759B
Common.class 751B
.classpath 10KB
org.eclipse.wst.common.component 469B
org.eclipse.wst.jsdt.ui.superType.container 49B
style.css 3KB
login.css 2KB
Thumbs.db 42KB
constituteTrain.gif 4KB
addEmployee.gif 4KB
constituteDeal.gif 4KB
constituteCompensation.gif 4KB
addInvite.gif 4KB
addDepartment.gif 4KB
land.gif 3KB
top-1.gif 2KB
top-2.gif 2KB
top-3.gif 2KB
top-11.gif 1KB
top-33.gif 1KB
top-22.gif 1KB
poi-ooxml-schemas-3.10.1-20140818.jar 4.72MB
poi-ooxml-schemas-3.9-20121203.jar 4.58MB
xmlbeans-2.6.0.jar 2.6MB
spring.jar 2.57MB
hibernate3.jar 2.08MB
poi-3.10.1-20140818.jar 1.86MB
classes12.jar 1.84MB
poi-3.9-20121203.jar 1.78MB
axis.jar 1.53MB
poi-3.6-20091214.jar 1.47MB
jfreechart-1.0.13.jar 1.36MB
poi-scratchpad-3.10.1-20140818.jar 1.18MB
poi-scratchpad-3.9-20121203.jar 1.17MB
jfreechart-1.0.5.jar 1.13MB
poi-ooxml-3.10.1-20140818.jar 1011KB
poi-ooxml-3.9-20121203.jar 915KB
mysql-connector-java-5.1.26-bin.jar 836KB
jxl-2.6.12.jar 709KB
mysql-connector-java-5.1.7-bin.jar 693KB
mysql-connector-java-5.1.6-bin.jar 687KB
jxl.jar 664KB
commons-collections-3.2.1.jar 562KB
commons-collections.jar 546KB
struts.jar 531KB
c3p0-0.9.0.jar 476KB
mysql-connector-java-3.1.12-bin.jar 436KB
antlr-2.7.6.jar 433KB
antlr-2.7.5H3.jar 423KB
poi-ooxml-3.6-20091214.jar 403KB
quartz-1.5.2.jar 380KB
fastjson-1.1.28.jar 354KB
velocity-1.4.jar 353KB
cglib-nodep-2.1_3.jar 317KB
dom4j-1.6.1.jar 307KB
poi-examples-3.10.1-20140818.jar 305KB
poi-examples-3.9-20121203.jar 302KB
jcommon-1.0.9.jar 298KB
commons-httpclient-3.1.jar 298KB
msbase.jar 278KB
sqljdbc.jar 247KB
commons-lang-2.3.jar 240KB
commons-beanutils-1.8.3.jar 227KB
gnujaxp.jar 226KB
spring-hibernate.jar 190KB
gson-2.2.1.jar 185KB
commons-beanutils.jar 184KB
commons-io-2.4.jar 181KB
commons-digester.jar 164KB
json-lib-2.2.3.jar 145KB
gson-2.2.1-sources.jar 123KB
junit.jar 118KB
commons-dbcp.jar 105KB
json.jar 92KB
commons-validator.jar 82KB
共 267 条
- 1
- 2
- 3
资源评论
- 赵广陆2020-03-14还不错,值得参考!
CharyLiu
- 粉丝: 106
- 资源: 35
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- 877668389368492摩托车队经理.apk
- IDM下载器官网免安装包,注册CMD文件,突破30天的限制
- qud.win.1.1-installer-10053.9.zip
- adb-r-linux.zip adb-r-linux.zip
- 对光伏出力预测的优化设计,实现了部分功能(注释完全,可直接运行)(文档加Matlab源码)
- 70-android.rules
- 可用于光伏出力预测,引入气象影响因子,效果良好(注释完全,可直接运行)(文档加Matlab源码)
- 利用白噪声特性和ARMR模型,通过求解模型参数生成随机风速(注释完全,可直接运行)(文档加Matlab源码)
- 51-android.rules
- RecationTest.zip
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功