1

 <%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib prefix="s" uri="/struts-tags" %> <html >
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
</head> <body>
<!-- <a href="emp_report.action?empId=0007" target="_blank">report</a>
<s:form action="emp_report.action">
<s:textfield name="empId"/>
<s:submit value="确定"/>
</s:form>-->
<script type="text/javascript">
var empDetailPanel = new EmpDetailPanel();
var w = Ext.getCmp('mainTab').getActiveTab().getInnerWidth();
var h = Ext.getCmp('mainTab').getActiveTab().getInnerHeight();
var activeTab = Ext.getCmp('empDetailPanelId');
if(activeTab){
activeTab.setHeight(h);
activeTab.setWidth(w);
}
//渲染
activeTab.render('empDetail');
</script>
<div id="empDetail"></div>
</body>
</html>

2.

 //创建一个员工个人信息面板
EmpDetailPanel = Ext.extend(Ext.Panel,{
id: 'empDetailPanelId',
constructor: function(){
EmpDetailPanel.superclass.constructor.call(this, {
items: [{
html: '<iframe src="" id="viewArea" width="100%" height="500" frameborder="0" scrolling="auto"></iframe>'
}],
tbar: new Ext.Toolbar({
items: ['员工工号',{
xtype: 'textfield',
id: 'report_empId',
width: 100,
listeners: {'blur': blurFn2}
},{
text: '详细PDF单个预览',
handler: this.viewFn
},'-',{
text: '简单PDF单个预览',
handler: this.simpleViewFn
},'-',{
text: '详细PDF单个导出',
handler: this.exportFn
},'-',{
text: '详细PDF全部导出',
handler: this.exportAllFn
},'-',{
text: '简单PDF导出',
handler: this.simplePdfExportFn
},'-',{
text: '简单PDF全部导出',
handler: this.simplePdfAllExportFn
},'-',{
text: '详细Excel全部导出',
handler: this.detailXlsAllExportFn
}]
})
})
},
//详细PDF单个预览
viewFn: function(){
var url = 'emp_detailPdfReport.action?empId=';
var empId = Ext.get('report_empId').dom.value;
if(empId == ''){
Ext.Msg.alert('提示','请输入工号');
return;
}
//更改Src属性刷新页面
Ext.get('viewArea').dom.src = url+empId;
},
//简单PDF单个预览
simpleViewFn: function(){
var url = 'emp_simplePdfReport.action?empId=';
var empId = Ext.get('report_empId').dom.value;
if(empId == ''){
Ext.Msg.alert('提示','请输入工号');
return;
}
Ext.get('viewArea').dom.src = url+empId;
},
//详细PDF单个导出
exportFn: function(){
var empId = Ext.get('report_empId').dom.value;
if(empId == ''){
Ext.Msg.alert('提示','请输入工号');
return;
}
document.location = 'emp_detailPdfExport.action?empId='+empId;
},
//详细PDF全部导出
exportAllFn: function(){
document.location = 'emp_detailPdfExport.action?empId=all';
},
//简单PDF导出
simplePdfExportFn : function(){
var empId = Ext.get('report_empId').dom.value;
if(empId == ''){
Ext.Msg.alert('提示','请输入工号');
return;
}
document.location = 'emp_simplePdfExport.action?empId='+empId;
},
//简单PDF全部导出
simplePdfAllExportFn: function(){
document.location = 'emp_simplePdfExport.action?empId=all';
},
//详细Excel全部导出
detailXlsAllExportFn: function(){
document.location = 'emp_detailXlsExport.action';
}
});
//焦点离开
blurFn2 = function(value){
var empId = value.getRawValue();
Ext.Ajax.request({
url: 'emp_isExist.action',
method: 'post',
params: {
empId: empId
},
success: isExistSuccessFn2,
failure: save_failure
})
};
//焦点离开成功
isExistSuccessFn2 = function(response, options){
if(response.responseText == ''){
Ext.Msg.alert('提示','此工号不存在');
}
}

3.员工个人信息Action

 package com.hrmsys.action;

 import java.io.File;
import java.io.IOException;
import java.io.PrintWriter;
import java.io.UnsupportedEncodingException;
import java.util.ArrayList;
import java.util.List; import javax.servlet.http.HttpServletResponse; import org.apache.struts2.ServletActionContext; import com.hrmsys.bean.EmployeeBean;
import com.hrmsys.model.Employee;
import com.hrmsys.model.User;
import com.hrmsys.service.EmpService;
import com.hrmsys.service.JobChangeService;
import com.hrmsys.util.ConditionValidate;
import com.hrmsys.util.CurrentDate;
import com.hrmsys.util.FileExport;
import com.hrmsys.util.SequenceBuilder;
import com.opensymphony.xwork2.ActionContext; public class EmpAction extends BaseAction{
private EmpService empService;
private Employee emp;
private List<EmployeeBean> empBeans;
private JobChangeService jobChangeService;
/**
* 由于dept和job常用,故单独成一js文件
* 但在与struts整合时不便将属性名绑定到name,
* 故此单独定义deptId和jobId属性
*/
private String deptId = null;
private String jobId = null;
private String empPhoto = null;
/**
* 配置文件中的参数会通过setter方法注入
* rePath获取savePath的值
*/
private String rePath = null;
/**
* 查询条目
*/
private String condition;
/**
* 查询内容
*/
private String conditionValue;
/**
* 保存的路径
*/
private String savePath;
/**
* 上传的文件内容
*/
private File upload;
/**
* 保存的文件名
*/
private String uploadFileName;
/**
* 上传的文件种类
*/
private String uploadContentType;
private String empId;
private String ids;
private String start;
private String limit; /************方法**********************************************/
/**
* 清单
*/
public void list(){
String json = null;
json = empService.getByHQL(deptId, condition, conditionValue, start, limit);
this.setStart(null);
this.setLimit(null);
this.out(json);
}
/**
* 保存员工信息
*/
public void save(){
log.info("save start....");
log.info(this.getEmpPhoto());
String msg = "保存失败";
HttpServletResponse response = this.getResponse();
User user = (User)ActionContext.getContext().getSession().get("user");
emp.setEmpPhoto(this.getEmpPhoto());
emp.setEmpAddDate(CurrentDate.getDate());
emp.setEmpAddPerson(user.getUserName());
msg = empService.save(emp);
this.out("{success: true, msg: '"+msg+"'}");
}
/**
* 员工头像上传
*/
public void upload(){
log.info("upload start...");
log.info("uploadFileName="+this.getUploadFileName());
//重命名
String fileName = SequenceBuilder.getSequence()+this.getUploadFileName().substring(this.getUploadFileName().indexOf("."));
String msg = empService.uploadPhoto(this.getSavePath()+"\\"+fileName, this.getUpload());
this.out("{success: true, msg: '"+msg+"', path: '"+this.rePath+"/"+fileName+"'}");
}
/**
* 根据工号判断是否存在此员工
*/
public void isExist(){
String empName = empService.isExistByEmpId(empId);
this.out(empName);
} public void unique(){
String emp = empService.unique(empId);
this.out(emp);
} public void delete(){
String filePath = ServletActionContext.getRequest().getRealPath(savePath);
String msg = empService.delete(ids, filePath);
this.out("{success: true, msg: '"+msg+"'}");
} public void intoUpdate(){
String empJson = empService.listByEmpId(empId);
this.out(empJson);
}
/**
* 详细员工pdf报表预览
*/
public String detailPdfReport(){
empBeans = empService.getEmpList(empId);
return "detailPdf";
}
public String simplePdfReport(){
empBeans = empService.getEmpList(empId);
return "simplePdf";
}
/**
* 导出详细报表pdf
*/
public void detailPdfExport(){
empService.pdfExport(empId, this.getResponse(),"员工详细信息.pdf","detailEmp.jasper");
}
/**
* 导出员工简单信息pdf
*/
public void simplePdfExport(){
empService.pdfExport(empId, this.getResponse(),"员工简单信息.pdf", "simpleEmp.jasper");
}
/**
* 导出员工简单信息Excel
*/
public void detailXlsExport(){
empService.xlsExport(this.getResponse(), "员工信息.xls");
}
/*********getter and setter ***********/
public EmpService getEmpService() {
return empService;
} public void setEmpService(EmpService empService) {
this.empService = empService;
} public String getDeptId() {
return deptId;
} public void setDeptId(String deptId) {
this.deptId = deptId;
} public String getCondition() {
return condition;
} public void setCondition(String condition) {
this.condition = condition;
} public String getConditionValue() {
return conditionValue;
} public void setConditionValue(String conditionValue) {
this.conditionValue = conditionValue;
} public Employee getEmp() {
return emp;
} public void setEmp(Employee emp) {
this.emp = emp;
}
public String getJobId() {
return jobId;
}
public void setJobId(String jobId) {
this.jobId = jobId;
}
public String getSavePath() {
//struts.xml中配置savePath参数,且获取文件夹的真实地址
return ServletActionContext.getRequest().getRealPath(savePath);
}
public void setSavePath(String savePath) {
this.rePath = savePath;
this.savePath = savePath;
}
public File getUpload() {
return upload;
}
public void setUpload(File upload) {
this.upload = upload;
}
public String getUploadFileName() {
return uploadFileName;
}
public void setUploadFileName(String uploadFileName) {
this.uploadFileName = uploadFileName;
}
public String getUploadContentType() {
return uploadContentType;
}
public void setUploadContentType(String uploadContentType) {
this.uploadContentType = uploadContentType;
}
public String getEmpPhoto() {
return empPhoto;
}
public void setEmpPhoto(String empPhoto) {
this.empPhoto = empPhoto;
}
public JobChangeService getJobChangeService() {
return jobChangeService;
}
public void setJobChangeService(JobChangeService jobChangeService) {
this.jobChangeService = jobChangeService;
}
public String getEmpId() {
return empId;
}
public void setEmpId(String empId) {
this.empId = empId;
}
public String getIds() {
return ids;
}
public void setIds(String ids) {
this.ids = ids;
}
public List<EmployeeBean> getEmpBeans() {
return empBeans;
}
public void setEmpBeans(List<EmployeeBean> empBeans) {
this.empBeans = empBeans;
}
public String getStart() {
return start;
}
public void setStart(String start) {
this.start = start;
}
public String getLimit() {
return limit;
}
public void setLimit(String limit) {
this.limit = limit;
} }

5.

 package com.hrmsys.service;

 import java.io.File;
import java.util.List; import javax.servlet.http.HttpServletResponse; import com.hrmsys.bean.EmployeeBean;
import com.hrmsys.model.Department;
import com.hrmsys.model.Employee; public interface EmpService {
/**
* 按部门编号查询部门总人数
* @param deptId
* @return
*/
int findNumByDept(Department dept);
/**
* 获取所有员工信息
* @return 以json形式返回
*/
String getAll(String start, String limit);
/**
* 按部门获取员工信息
* @return 以json形式返回
*/
String findByDeptId(String deptId);
/**
* 按条件查询员工表
* @param deptId 部门ID
* @param condition 查询条目
* @param conditionValue 查询内容
* @return 返回Json.toString()
*/
String getByHQL(String deptId, String condition, String conditionValue, String start, String limit);
/**
* 保存员工信息
* @param emp
*/
String save(Employee emp);
/**
* 图片上传处理
* @param savePath 保存的位置
* @param upload 上传的文件
* @return msg返回结果
*/
String uploadPhoto(String savePath, File upload);
/**
* 判断员工是否存在
* @param empId
* @return
*/
String isExistByEmpId(String empId);
/**
* 删除
* @param ids
* @return
*/
String delete(String ids, String filePath);
/**
* 按empId查询
* @param empId
* @return
*/
String listByEmpId(String empId); /**
* 导员工pdf信息
* @param empId
*/
void pdfExport(String empId, HttpServletResponse response, String filename, String jasper);
List<EmployeeBean> getEmpList(String empId);
/**
* 导出Excel
* @param response
* @param string
* @param string2
*/
void xlsExport(HttpServletResponse response, String filename); String unique(String empId);
}

6.

 package com.hrmsys.service.impl;

 import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List; import javax.servlet.http.HttpServletResponse; import net.sf.json.JSONArray; import com.hrmsys.bean.EmployeeBean;
import com.hrmsys.bean.PageBean;
import com.hrmsys.dao.EmployeeDAO;
import com.hrmsys.enums.StaticValue;
import com.hrmsys.model.Department;
import com.hrmsys.model.Employee;
import com.hrmsys.service.EmpService;
import com.hrmsys.util.ConditionValidate;
import com.hrmsys.util.FileExport; public class EmpServiceImpl implements EmpService { private EmployeeDAO empDAO; @Override
public int findNumByDept(Department dept) {
List<Employee> emps = empDAO.findByDept(dept);
if (emps != null)
return emps.size();
return 0;
} public EmployeeDAO getEmpDAO() {
return empDAO;
} public void setEmpDAO(EmployeeDAO empDAO) {
this.empDAO = empDAO;
} @Override
public String getAll(String start, String limit) {
List<Employee> emps = empDAO.findAll(Integer.parseInt(start), Integer.parseInt(limit));
String json = null;
if (emps.size() != 0) {
json = JSONArray.fromObject(emps).toString();
}
int totalProperty = empDAO.findTotal(Employee.class);
return "{totalProperty:"+totalProperty+",root:"+json+"}";
} @Override
public String findByDeptId(String deptId) {
Department dept = new Department();
dept.setDeptId(deptId);
List<Employee> emps = empDAO.findByDept(dept);
String json = JSONArray.fromObject(emps).toString();
return json;
} @Override
public String getByHQL(String deptId, String condition,
String conditionValue, String start, String limit) { PageBean pageBean = empDAO.findByHQL(deptId, condition,
conditionValue, Integer.parseInt(start), Integer.parseInt(limit));
String json = JSONArray.fromObject(pageBean.getRoot()).toString();
return "{totalProperty:"+pageBean.getTotalProperty()+",root:"+json+"}";
} @Override
public String save(Employee emp) {
if (empDAO.saveOrUpdate(emp)) {
return StaticValue.SAVE_SUCCESS;
}
return StaticValue.SAVE_FAILURE;
} @Override
public String uploadPhoto(String savePath, File upload) {
boolean flag = true;
String msg = null;
try {
FileOutputStream fos = new FileOutputStream(savePath);
FileInputStream fis = new FileInputStream(upload);
byte[] buffer = new byte[1024];
int len = 0;
while ((len = fis.read(buffer)) > 0) {
fos.write(buffer, 0, len);
}
} catch (FileNotFoundException e) {
flag = false;
e.printStackTrace();
} catch (IOException e) {
flag = false;
e.printStackTrace();
} finally {
if (flag) {
msg = StaticValue.UPLOAD_SUCCESS;
} else {
msg = StaticValue.UPLOAD_FAILURE;
}
}
return msg;
} @Override
public String isExistByEmpId(String empId) {
Employee emp = empDAO.findByEmpId(empId);
if(null != emp){
return emp.getEmpName();
}
return "";
} @Override
public String unique(String empId) {
Employee emp = empDAO.findByEmpId(empId);
if(null != emp){
return JSONArray.fromObject(emp).toString();
}
return "";
} @Override
public String delete(String ids, String filePath) {
String[] empIds = ids.split(",");
for(String empId : empIds){
Employee emp = empDAO.findByEmpId(empId);
String urlPath = emp.getEmpPhoto();
if(urlPath.indexOf("default.gif") <){ //默认图片不删除
int position = urlPath.lastIndexOf("/");
File file=new File(filePath +"\\"+ urlPath.substring(position, urlPath.length()));
if(file.exists() && file.isFile())
file.delete();
}
}
if(empDAO.deleteByEmpId(empIds)){
return StaticValue.DELETE_SUCCESS;
}
return StaticValue.DELETE_FAILURE;
} @Override
public String listByEmpId(String empId) {
Employee emp = empDAO.findByEmpId(empId);
return JSONArray.fromObject(emp).toString();
} public List<EmployeeBean> packageEmp(List<Employee> emps) {
List<EmployeeBean> empBeans = new ArrayList<EmployeeBean>();
for(Employee emp : emps){
EmployeeBean empBean = new EmployeeBean();
empBean.setEmpAccount(emp.getEmpAccount());
empBean.setEmpAddress(emp.getEmpAddress());
empBean.setEmpBank(emp.getEmpBank());
empBean.setEmpBirth(emp.getEmpBirth());
empBean.setEmpEducation(emp.getEmpEducation());
empBean.setEmpEmail(emp.getEmpEmail());
empBean.setEmpId(emp.getEmpId());
empBean.setEmpIdcard(emp.getEmpIdcard());
empBean.setEmpMobilephone(emp.getEmpMobilephone());
empBean.setEmpName(emp.getEmpName());
empBean.setEmpNation(emp.getEmpNation());
empBean.setEmpNationality(emp.getEmpNation());
empBean.setEmpOrigin(emp.getEmpOrigin());
empBean.setEmpPhoto(emp.getEmpPhoto());
empBean.setEmpPost(emp.getEmpPost());
empBean.setEmpProfession(emp.getEmpProfession());
empBean.setEmpQq(emp.getEmpQq());
empBean.setEmpSchool(emp.getEmpSchool());
if(emp.getEmpSex() == 1){
empBean.setEmpSex("男");
}else{
empBean.setEmpSex("女");
}
empBean.setEmpTelephone(emp.getEmpTelephone());
empBean.setJob(emp.getJob().getJobName());
empBean.setDept(emp.getDepartment().getDeptName());
empBeans.add(empBean);
} return empBeans;
} @Override
public void pdfExport(String empId, HttpServletResponse response, String filename, String jasper) {
Employee emp = null;
List<Employee> emps = new ArrayList<Employee>();
if(!"all".equals(empId) && ConditionValidate.isEmpty(empId)){
emp = empDAO.findByEmpId(empId);
emps.add(emp);
}else{
emps = empDAO.findAll(Employee.class);
}
List<EmployeeBean> empBeans = packageEmp(emps);
FileExport fileExport = new FileExport();
fileExport.exportPDF(empBeans, filename,jasper, response); } @Override
public List<EmployeeBean> getEmpList(String empId) {
List<Employee> emps = new ArrayList<Employee>();
Employee emp = empDAO.findByEmpId(empId);
emps.add(emp);
return this.packageEmp(emps);
} @Override
public void xlsExport(HttpServletResponse response, String filename) {
List<Employee> emps = empDAO.findAll(Employee.class);
List<EmployeeBean> empBeans = this.packageEmp(emps);
FileExport fileExport = new FileExport();
fileExport.exportXls(empBeans, filename, response);
} }

8.

 <?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE struts PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 2.1//EN" "http://struts.apache.org/dtds/struts-2.1.dtd">
<struts>
<constant name="struts.i18n.encoding" value="UTF-8"/>
<constant name="struts.devMode" value="false"/>
<package name="default" extends="struts-default,jasperreports-default" namespace="/">
<global-results >
<result name="input">error.jsp</result>
</global-results> <action name="user_*" class="userAction" method="{1}">
<result name="success" type="redirect">jsp/main.jsp</result>
<result name="input">index.jsp</result>
<result name="exit" type="redirect">index.jsp</result>
</action>
<action name="menu" class="menuAction" method="load"></action>
<action name="dept_*" class="deptAction" method="{1}"></action>
<action name="job_*" class="jobAction" method="{1}"></action>
<action name="emp_*" class="empAction" method="{1}">
<param name="savePath">photo</param>
<result name="detailPdf" type="jasper">
<param name="location">jasperreport/detailEmp.jasper</param>
<param name="dataSource">empBeans</param>
<param name="format">PDF</param>
</result>
<result name="simplePdf" type="jasper">
<param name="location">jasperreport/simpleEmp.jasper</param>
<param name="dataSource">empBeans</param>
<param name="format">PDF</param>
</result>
</action>
<action name="jobChange_*" class="jobChangeAction" method="{1}"></action>
<action name="rec_*" class="recruitmentAction" method="{1}"></action>
<action name="train_*" class="trainAction" method="{1}"></action>
<action name="tRecord_*" class="tRecordAction" method="{1}"></action>
<action name="ePunish_*" class="ePunishAction" method="{1}"></action>
<action name="revenue_*" class="revenueAction" method="{1}"></action>
<action name="boon_*" class="boonAction" method="{1}"></action>
<action name="salBasic_*" class="salaryBasicAction" method="{1}"></action>
<action name="salary_*" class="salaryAction" method="{1}">
<result name="salView" type="jasper">
<param name="location">jasperreport/salary.jasper</param>
<param name="dataSource">salBeans</param>
<param name="format">PDF</param>
</result>
</action>
<action name="permission_*" class="permissionAction" method="{1}"></action>
<action name="role_*" class="roleAction" method="{1}"></action>
<action name="rolePer_*" class="rolePermissionAction" method="{1}"></action>
<action name="recruitment_*" class="recruitmentAction" method="{1}"></action>
<action name="*">
<result>{1}.jsp</result>
</action>
</package>
</struts>

8.

 package com.hrmsys.util;

 import java.io.File;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.util.List; import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletResponse; import net.sf.jasperreports.engine.JRDataSource;
import net.sf.jasperreports.engine.JRExporterParameter;
import net.sf.jasperreports.engine.JasperFillManager;
import net.sf.jasperreports.engine.JasperPrint;
import net.sf.jasperreports.engine.JasperReport;
import net.sf.jasperreports.engine.data.JRBeanCollectionDataSource;
import net.sf.jasperreports.engine.export.JRPdfExporter;
import net.sf.jasperreports.engine.util.JRLoader; 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.struts2.ServletActionContext; import com.hrmsys.bean.EmployeeBean; public class FileExport {
/**
* pdf导出
*
* @param list
* 数据集合
* @param filename
* 导出的文件名称
* @param response
* HttpServletResponse
* @return
*/
public void exportPDF(List list, String filename, String jaspername,
HttpServletResponse response) {
ServletOutputStream sos = null;
try {
String path = ServletActionContext.getServletContext().getRealPath(
"").replace("\\", "/");
File file = new File(path + "/jasperreport/" + jaspername);
//数据源就构造完毕
JRDataSource dataSource = new JRBeanCollectionDataSource(list);
//加载jasper
JasperReport report = (JasperReport) JRLoader.loadObject(file
.getPath());
//将数据和xml组合,生成需要的打印文件
JasperPrint print = JasperFillManager.fillReport(report, null,
dataSource);
////生成我们的导出类JRPdfExporter 来自JRExporter
JRPdfExporter exporter = new JRPdfExporter();
response.setContentType("application/pdf");
response.setHeader("Content-Disposition", "attachment;filename="
+ new String(filename.getBytes(), "ISO8859-1"));//转为此不会中文乱码
sos = response.getOutputStream();
///设JasperPrint参数
exporter.setParameter(JRExporterParameter.JASPER_PRINT, print);
//设置输入的PDF文件放在什么地方
exporter.setParameter(JRExporterParameter.OUTPUT_STREAM, sos);
// //输出
exporter.exportReport();
} catch (Exception e) {
e.printStackTrace();
} finally {
if (sos != null) {
try {
sos.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
} // /**
// * 把字符串转成utf8编码,保证中文文件名不会乱码
// * new String(filename.getByte("UTF-8"),"UTF-8");不行
// * @param s
// * @return foxmail
// */
// public static String toUtf8String(String s) {
// StringBuffer sb = new StringBuffer();
// for (int i = 0; i < s.length(); i++) {
// char c = s.charAt(i);
// if (c >= 0 && c <= 255) {
// sb.append(c);
// } else {
// byte[] b;
// try {
// b = Character.toString(c).getBytes("utf-8");
// } catch (Exception ex) {
// System.out.println(ex);
// b = new byte[0];
// }
// for (int j = 0; j < b.length; j++) {
// int k = b[j];
// if (k < 0)
// k += 256;
// sb.append("%" + Integer.toHexString(k).toUpperCase());
// }
// }
// }
// return sb.toString();
// }
/**
* jasperReport导出Excel 此方式导出的excel没有网格线(好像直接用流导出方式都没有)
* 在此直接用poi导出,当然jasperReport导出中也应用了poi(需要加入poi的jar包)
*/
public void exportXls(List<EmployeeBean> list, String filename, HttpServletResponse response) {
//创建一工作空间
HSSFWorkbook workbook = new HSSFWorkbook();
//创建一表单
HSSFSheet sheet = workbook.createSheet(filename);
//创建表题行
HSSFRow headerRow = sheet.createRow(0);
for(int i = 0; i <; i++){
HSSFCell headerCell = headerRow.createCell(i);
switch(i){
case 0 :
headerCell.setCellValue("员工工号"); break;
case 1 :
headerCell.setCellValue("员工姓名"); break;
case 2 :
headerCell.setCellValue("性别"); break;
case 3 :
headerCell.setCellValue("出生日期"); break;
case 4 :
headerCell.setCellValue("地址"); break;
case 5:
headerCell.setCellValue("邮编"); break;
case 6 :
headerCell.setCellValue("电话"); break;
case 7 :
headerCell.setCellValue("手机"); break;
case 8 :
headerCell.setCellValue("QQ"); break;
case 9 :
headerCell.setCellValue("email"); break;
case 10 :
headerCell.setCellValue("银行账号"); break;
case 11 :
headerCell.setCellValue("身份证号"); break;
case 12 :
headerCell.setCellValue("部门"); break;
case 13 :
headerCell.setCellValue("职位"); break;
case 14 :
headerCell.setCellValue("国籍"); break;
case 15 :
headerCell.setCellValue("籍贯"); break;
case 16 :
headerCell.setCellValue("民族"); break;
case 17 :
headerCell.setCellValue("毕业学校"); break;
case 18 :
headerCell.setCellValue("学历"); break;
case 19 :
headerCell.setCellValue("专业"); break;
}
}
for(int i = 0; i < list.size(); i++){
HSSFRow row = sheet.createRow(i+1);
EmployeeBean empBean = list.get(i);
HSSFCell empIdCell = row.createCell(0);
empIdCell.setCellValue(empBean.getEmpId());
HSSFCell empNameCell = row.createCell(1);
empNameCell.setCellValue(empBean.getEmpName());
HSSFCell empSexCell = row.createCell(2);
empSexCell.setCellValue(empBean.getEmpSex());
HSSFCell empBirthCell = row.createCell(3);
empBirthCell.setCellValue(empBean.getEmpBirth());
HSSFCell empAddressCell = row.createCell(4);
empAddressCell.setCellValue(empBean.getEmpAddress());
HSSFCell empPostCell = row.createCell(5);
empPostCell.setCellValue(empBean.getEmpPost());
HSSFCell empTelephoneCell = row.createCell(6);
empTelephoneCell.setCellValue(empBean.getEmpTelephone());
HSSFCell empMobilephoneCell = row.createCell(7);
empMobilephoneCell.setCellValue(empBean.getEmpMobilephone());
HSSFCell empQqphoneCell = row.createCell(8);
empQqphoneCell.setCellValue(empBean.getEmpQq());
HSSFCell empEmailCell = row.createCell(9);
empEmailCell.setCellValue(empBean.getEmpEmail());
HSSFCell empAccountCell = row.createCell(10);
empAccountCell.setCellValue(empBean.getEmpAccount());
HSSFCell empIdcardCell = row.createCell(11);
empIdcardCell.setCellValue(empBean.getEmpIdcard());
HSSFCell deptCell = row.createCell(12);
deptCell.setCellValue(empBean.getDept());
HSSFCell jobCell = row.createCell(13);
jobCell.setCellValue(empBean.getJob());
HSSFCell empNationalityCell = row.createCell(14);
empNationalityCell.setCellValue(empBean.getEmpNationality());
HSSFCell empOriginCell = row.createCell(15);
empOriginCell.setCellValue(empBean.getEmpOrigin());
HSSFCell empNationCell = row.createCell(16);
empNationCell.setCellValue(empBean.getEmpNation());
HSSFCell empSchoolCell = row.createCell(17);
empSchoolCell.setCellValue(empBean.getEmpSchool());
HSSFCell empEducationCell = row.createCell(18);
empEducationCell.setCellValue(empBean.getEmpEducation());
HSSFCell empProfessionCell = row.createCell(19);
empProfessionCell.setCellValue(empBean.getEmpProfession());
}
response.setContentType("application/xls");
ServletOutputStream sos = null;
try {
response.setHeader("Content-Disposition", "attachment;filename="
+ new String(filename.getBytes(), "ISO8859-1"));
sos = response.getOutputStream();
workbook.write(sos);
} catch (Exception e) {
e.printStackTrace();
}finally{
if(sos != null){
try {
sos.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
}
}

78.员工个人信息保镖页面 Extjs 页面的更多相关文章

  1. 83.个人信息维护页面 Extjs 页面

    1 <%@ page language="java" import="java.util.*" pageEncoding="UTF-8" ...

  2. 61.员工信息管理Extjs 页面

    1.员工信息管理jsp <%@ page language="java" pageEncoding="UTF-8"%> <script typ ...

  3. `<jsp:getProperty>`动作和`<jsp:setProperty>`动作的使用在一个静态页面填写图书的基本信息,页面信息提交给其他页面,并且在其页面显示。要去将表单元素的值赋值给Java

    <jsp:getProperty>动作和<jsp:setProperty>动作的使用 1.<jsp:getProperty>动作 语法格式: <jsp:get ...

  4. Ajax案例:三级联动查询员工的信息(三张表进行内连接)

    需求分析: 通过数据库连接池,可以查询到数据库中员工的各种信息,通过点击下拉框的方式实现三级联动,即:没有点击city下拉框,后面两个下拉框中没有值,这样,点击city下拉框,department下拉 ...

  5. /*使用PHP创建一个数组,保存5個员工的信息(ename/sex/salary/birthday/pic)*/

    <?php/*使用PHP创建一个数组,保存5個员工的信息(ename/sex/salary/birthday/pic)*/$empList=[    ['ename'=>'张学友','se ...

  6. 继 S-HR之代码创建临时表并插入数据 完整功能之员工职业信息变更报表

    目的示例1: 制作员工职业信息报表[S-HR系统的报表其实就是列表o.0,醉了] EcirrWithPP.js shr.defineClass("shr.custom.EcirrWithPP ...

  7. js之iframe子页面与父页面通信

    iframe子页面与父页面通信根据iframe中src属性是同域链接还是跨域链接,通信方式也不同. 一.同域下父子页面的通信 父页面parent.html <html> <head& ...

  8. Web设计中打开新页面或页面跳转的方法 js跳转页面

    Web设计中打开新页面或页面跳转的方法 一.asp.net c# 打开新页面或页面跳转 1. 最常用的页面跳转(原窗口被替代):Response.Redirect("newpage.aspx ...

  9. Web设计中打开新页面或页面跳转的方法

    一.asp.net c# 打开新页面或页面跳转 1. 最常用的页面跳转(原窗口被替代):Response.Redirect("newpage.aspx"); 2. 利用url地址打 ...

随机推荐

  1. 关于java 关键字enum不识别的解决办法

    从别人那儿拷贝过来的myeclipse java工程,打开一看标红了一大片,仔细一看,原来是不识别enum关键字,这就有点尴尬了. 我自己重新建了一个java工程,测试了下,假如我在新建工程的时候选择 ...

  2. 配置Android的NDK开发环境(eclipse)

    ndk下载地址: http://blog.csdn.net/zhanghuoding/article/details/51345256 在eclipse设置ndk位置 右键你的工程,android t ...

  3. CAD实现自定义实体夹点移动(com接口VB语言)

    主要用到函数说明: MxDrawXCustomEvent::MxDrawXCustomEntity::moveGripPointsAt 自定义实体事件,自定义实体夹点被移动,详细说明如下: 参数 说明 ...

  4. Java数组数据类型

    Java数组数据类型 数组是多个相同类型的数据的组合,数组中的元素可以是任何类型的数据: 一维数组 package com.ahabest.array; public class ArratTest ...

  5. BZOJ 2096: [Poi2010]Pilots 单调队列

    Code: #include<bits/stdc++.h> #define maxn 4000000 using namespace std; void setIO(string s) { ...

  6. Fang Fang HDU - 5455 (思维题)

    Fang Fang says she wants to be remembered. I promise her. We define the sequence FF of strings. F0 = ...

  7. 通过git向github提交项目

    按顺序学习 https://www.cnblogs.com/forget406/p/6045499.html#top https://blog.csdn.net/xiaoputao0903/artic ...

  8. Huawei-R&S-网络工程师实验笔记20190609-VLAN划分综合(Hybrid端口)

    >Huawei-R&S-网络工程师实验笔记20190609-VLAN划分综合(Hybrid端口) >>实验开始,先上拓扑图参考: >>>实验目标:分别实现主 ...

  9. 获取当前日期,或指定日期的农历js代码

    时间不早了,直接上代码啦-- var CalendarData=new Array(100);var madd=new Array(12);var tgString="甲乙丙丁戊己庚辛壬癸& ...

  10. 【codeforces 801B】Valued Keys

    [题目链接]:http://codeforces.com/contest/801/problem/B [题意] 定义一个对两个字符串x,y的f(x,y)函数; 返回的是一个字符串; 这个返回的字符串的 ...