7 个解决方案
#1
每天做。。。但是公司项目代码不好发。。。
功能是公司框架有的,重实现下就行了。
你可以百度 poi
功能是公司框架有的,重实现下就行了。
你可以百度 poi
#2
然后你可以结贴了
0.00%
0.00%
#3
不行,我要jxl的
#4
大家好,我要JXL的
#5
struts2.0实现导出很简单
<action name="MetMbrInfoE_*" class="com.app.web.meeting.action.MeetingInfoAction" method="{1}">
<result name="exp" type="stream">
<param name="contentType">application/vnd.ms-excel</param>
<param name="inputName">excelStream</param>
<param name="contentDisposition">attachment;filename="${fileName}.xls"</param>
<param name="bufferSize">1024</param>
</result>
</action>
/**
* 导出excel表格
*/
public String exp() throws Exception{
HttpServletRequest request = (HttpServletRequest) ActionContext.getContext().get(StrutsStatics.HTTP_REQUEST);
String metname = NFUtil.null2String(request.getParameter("inMeetingInfo.meetingName"));
String roomName = NFUtil.null2String(request.getParameter("inMeetingInfo.roomName"));
String userName = NFUtil.null2String(request.getParameter("inMeetingInfo.userName"));
String signStat = NFUtil.null2String(request.getParameter("inMeetingInfo.signStat"));
MeetingInfo meetInfo = new MeetingInfo();
if(!"".equals(metname)){
meetInfo.setMeetingName(metname);
}
if(!"".equals(roomName)){
meetInfo.setRoomName(roomName);
}
if(!"".equals(userName)){
meetInfo.setUserName(userName);
}
if(!"".equals(signStat)){
meetInfo.setSignStat(signStat);
}
Condition[] conds = new Condition[2];
conds[0]=OrderBy.desc("meetingId");
conds[1]=OrderBy.desc("signStat");
List<MeetingInfo> ls = this.meetingInfoService.listAll(meetInfo, MatchMode.ANYWHERE, conds, null);
ByteArrayOutputStream os = new ByteArrayOutputStream();
if(ls!=null){
HSSFWorkbook wb = new HSSFWorkbook();
HSSFSheet sheet =null;
sheet = wb.createSheet("会议签到统计");
HSSFRow headrow = sheet.createRow(0);
headrow.createCell((short) 0).setCellValue("会议名称");
headrow.createCell((short) 1).setCellValue("会议室");
headrow.createCell((short) 2).setCellValue("姓名");
headrow.createCell((short) 3).setCellValue("证件号码");
headrow.createCell((short) 4).setCellValue("签到时间");
headrow.createCell((short) 5).setCellValue("签到状态");
int k=0;
for(int i=0;i<ls.size();i++){
MeetingInfo meetInf = ls.get(i);
k++;
HSSFRow row = sheet.createRow(k);
row.createCell((short) 0).setCellValue(meetInf.getMeetingName());
row.createCell((short) 1).setCellValue(meetInf.getRoomName());
row.createCell((short) 2).setCellValue(meetInf.getUserName());
row.createCell((short) 3).setCellValue(meetInf.getIdCard());
String signflag = meetInf.getSignStat();
String signstat = "缺席";
if(signflag.equals("1")){
signstat ="正常";
}else if(signflag.equals("2")){
signstat ="迟到";
}else{
signstat = "缺席";
}
row.createCell((short) 4).setCellValue(NFUtil.date2String(meetInf.getPunchTime(), "yyyy-MM-dd HH:mm:ss"));
row.createCell((short) 5).setCellValue(signstat);
}
workbook2InputStream(wb,NFUtil.date2String(new Date(), "yyyyMMddHHmmss"));
}
return "exp";
}
<action name="MetMbrInfoE_*" class="com.app.web.meeting.action.MeetingInfoAction" method="{1}">
<result name="exp" type="stream">
<param name="contentType">application/vnd.ms-excel</param>
<param name="inputName">excelStream</param>
<param name="contentDisposition">attachment;filename="${fileName}.xls"</param>
<param name="bufferSize">1024</param>
</result>
</action>
/**
* 导出excel表格
*/
public String exp() throws Exception{
HttpServletRequest request = (HttpServletRequest) ActionContext.getContext().get(StrutsStatics.HTTP_REQUEST);
String metname = NFUtil.null2String(request.getParameter("inMeetingInfo.meetingName"));
String roomName = NFUtil.null2String(request.getParameter("inMeetingInfo.roomName"));
String userName = NFUtil.null2String(request.getParameter("inMeetingInfo.userName"));
String signStat = NFUtil.null2String(request.getParameter("inMeetingInfo.signStat"));
MeetingInfo meetInfo = new MeetingInfo();
if(!"".equals(metname)){
meetInfo.setMeetingName(metname);
}
if(!"".equals(roomName)){
meetInfo.setRoomName(roomName);
}
if(!"".equals(userName)){
meetInfo.setUserName(userName);
}
if(!"".equals(signStat)){
meetInfo.setSignStat(signStat);
}
Condition[] conds = new Condition[2];
conds[0]=OrderBy.desc("meetingId");
conds[1]=OrderBy.desc("signStat");
List<MeetingInfo> ls = this.meetingInfoService.listAll(meetInfo, MatchMode.ANYWHERE, conds, null);
ByteArrayOutputStream os = new ByteArrayOutputStream();
if(ls!=null){
HSSFWorkbook wb = new HSSFWorkbook();
HSSFSheet sheet =null;
sheet = wb.createSheet("会议签到统计");
HSSFRow headrow = sheet.createRow(0);
headrow.createCell((short) 0).setCellValue("会议名称");
headrow.createCell((short) 1).setCellValue("会议室");
headrow.createCell((short) 2).setCellValue("姓名");
headrow.createCell((short) 3).setCellValue("证件号码");
headrow.createCell((short) 4).setCellValue("签到时间");
headrow.createCell((short) 5).setCellValue("签到状态");
int k=0;
for(int i=0;i<ls.size();i++){
MeetingInfo meetInf = ls.get(i);
k++;
HSSFRow row = sheet.createRow(k);
row.createCell((short) 0).setCellValue(meetInf.getMeetingName());
row.createCell((short) 1).setCellValue(meetInf.getRoomName());
row.createCell((short) 2).setCellValue(meetInf.getUserName());
row.createCell((short) 3).setCellValue(meetInf.getIdCard());
String signflag = meetInf.getSignStat();
String signstat = "缺席";
if(signflag.equals("1")){
signstat ="正常";
}else if(signflag.equals("2")){
signstat ="迟到";
}else{
signstat = "缺席";
}
row.createCell((short) 4).setCellValue(NFUtil.date2String(meetInf.getPunchTime(), "yyyy-MM-dd HH:mm:ss"));
row.createCell((short) 5).setCellValue(signstat);
}
workbook2InputStream(wb,NFUtil.date2String(new Date(), "yyyyMMddHHmmss"));
}
return "exp";
}
#6
上传、下载、读excel的源代码网上一大堆
现成的谁能给你!
现成的谁能给你!
#7
http://download.csdn.net/detail/ading_25/3166293
导入数据到excel模板, 读/写。。。自己参考吧,和你说的功能有点出入
#1
每天做。。。但是公司项目代码不好发。。。
功能是公司框架有的,重实现下就行了。
你可以百度 poi
功能是公司框架有的,重实现下就行了。
你可以百度 poi
#2
然后你可以结贴了
0.00%
0.00%
#3
不行,我要jxl的
#4
大家好,我要JXL的
#5
struts2.0实现导出很简单
<action name="MetMbrInfoE_*" class="com.app.web.meeting.action.MeetingInfoAction" method="{1}">
<result name="exp" type="stream">
<param name="contentType">application/vnd.ms-excel</param>
<param name="inputName">excelStream</param>
<param name="contentDisposition">attachment;filename="${fileName}.xls"</param>
<param name="bufferSize">1024</param>
</result>
</action>
/**
* 导出excel表格
*/
public String exp() throws Exception{
HttpServletRequest request = (HttpServletRequest) ActionContext.getContext().get(StrutsStatics.HTTP_REQUEST);
String metname = NFUtil.null2String(request.getParameter("inMeetingInfo.meetingName"));
String roomName = NFUtil.null2String(request.getParameter("inMeetingInfo.roomName"));
String userName = NFUtil.null2String(request.getParameter("inMeetingInfo.userName"));
String signStat = NFUtil.null2String(request.getParameter("inMeetingInfo.signStat"));
MeetingInfo meetInfo = new MeetingInfo();
if(!"".equals(metname)){
meetInfo.setMeetingName(metname);
}
if(!"".equals(roomName)){
meetInfo.setRoomName(roomName);
}
if(!"".equals(userName)){
meetInfo.setUserName(userName);
}
if(!"".equals(signStat)){
meetInfo.setSignStat(signStat);
}
Condition[] conds = new Condition[2];
conds[0]=OrderBy.desc("meetingId");
conds[1]=OrderBy.desc("signStat");
List<MeetingInfo> ls = this.meetingInfoService.listAll(meetInfo, MatchMode.ANYWHERE, conds, null);
ByteArrayOutputStream os = new ByteArrayOutputStream();
if(ls!=null){
HSSFWorkbook wb = new HSSFWorkbook();
HSSFSheet sheet =null;
sheet = wb.createSheet("会议签到统计");
HSSFRow headrow = sheet.createRow(0);
headrow.createCell((short) 0).setCellValue("会议名称");
headrow.createCell((short) 1).setCellValue("会议室");
headrow.createCell((short) 2).setCellValue("姓名");
headrow.createCell((short) 3).setCellValue("证件号码");
headrow.createCell((short) 4).setCellValue("签到时间");
headrow.createCell((short) 5).setCellValue("签到状态");
int k=0;
for(int i=0;i<ls.size();i++){
MeetingInfo meetInf = ls.get(i);
k++;
HSSFRow row = sheet.createRow(k);
row.createCell((short) 0).setCellValue(meetInf.getMeetingName());
row.createCell((short) 1).setCellValue(meetInf.getRoomName());
row.createCell((short) 2).setCellValue(meetInf.getUserName());
row.createCell((short) 3).setCellValue(meetInf.getIdCard());
String signflag = meetInf.getSignStat();
String signstat = "缺席";
if(signflag.equals("1")){
signstat ="正常";
}else if(signflag.equals("2")){
signstat ="迟到";
}else{
signstat = "缺席";
}
row.createCell((short) 4).setCellValue(NFUtil.date2String(meetInf.getPunchTime(), "yyyy-MM-dd HH:mm:ss"));
row.createCell((short) 5).setCellValue(signstat);
}
workbook2InputStream(wb,NFUtil.date2String(new Date(), "yyyyMMddHHmmss"));
}
return "exp";
}
<action name="MetMbrInfoE_*" class="com.app.web.meeting.action.MeetingInfoAction" method="{1}">
<result name="exp" type="stream">
<param name="contentType">application/vnd.ms-excel</param>
<param name="inputName">excelStream</param>
<param name="contentDisposition">attachment;filename="${fileName}.xls"</param>
<param name="bufferSize">1024</param>
</result>
</action>
/**
* 导出excel表格
*/
public String exp() throws Exception{
HttpServletRequest request = (HttpServletRequest) ActionContext.getContext().get(StrutsStatics.HTTP_REQUEST);
String metname = NFUtil.null2String(request.getParameter("inMeetingInfo.meetingName"));
String roomName = NFUtil.null2String(request.getParameter("inMeetingInfo.roomName"));
String userName = NFUtil.null2String(request.getParameter("inMeetingInfo.userName"));
String signStat = NFUtil.null2String(request.getParameter("inMeetingInfo.signStat"));
MeetingInfo meetInfo = new MeetingInfo();
if(!"".equals(metname)){
meetInfo.setMeetingName(metname);
}
if(!"".equals(roomName)){
meetInfo.setRoomName(roomName);
}
if(!"".equals(userName)){
meetInfo.setUserName(userName);
}
if(!"".equals(signStat)){
meetInfo.setSignStat(signStat);
}
Condition[] conds = new Condition[2];
conds[0]=OrderBy.desc("meetingId");
conds[1]=OrderBy.desc("signStat");
List<MeetingInfo> ls = this.meetingInfoService.listAll(meetInfo, MatchMode.ANYWHERE, conds, null);
ByteArrayOutputStream os = new ByteArrayOutputStream();
if(ls!=null){
HSSFWorkbook wb = new HSSFWorkbook();
HSSFSheet sheet =null;
sheet = wb.createSheet("会议签到统计");
HSSFRow headrow = sheet.createRow(0);
headrow.createCell((short) 0).setCellValue("会议名称");
headrow.createCell((short) 1).setCellValue("会议室");
headrow.createCell((short) 2).setCellValue("姓名");
headrow.createCell((short) 3).setCellValue("证件号码");
headrow.createCell((short) 4).setCellValue("签到时间");
headrow.createCell((short) 5).setCellValue("签到状态");
int k=0;
for(int i=0;i<ls.size();i++){
MeetingInfo meetInf = ls.get(i);
k++;
HSSFRow row = sheet.createRow(k);
row.createCell((short) 0).setCellValue(meetInf.getMeetingName());
row.createCell((short) 1).setCellValue(meetInf.getRoomName());
row.createCell((short) 2).setCellValue(meetInf.getUserName());
row.createCell((short) 3).setCellValue(meetInf.getIdCard());
String signflag = meetInf.getSignStat();
String signstat = "缺席";
if(signflag.equals("1")){
signstat ="正常";
}else if(signflag.equals("2")){
signstat ="迟到";
}else{
signstat = "缺席";
}
row.createCell((short) 4).setCellValue(NFUtil.date2String(meetInf.getPunchTime(), "yyyy-MM-dd HH:mm:ss"));
row.createCell((short) 5).setCellValue(signstat);
}
workbook2InputStream(wb,NFUtil.date2String(new Date(), "yyyyMMddHHmmss"));
}
return "exp";
}
#6
上传、下载、读excel的源代码网上一大堆
现成的谁能给你!
现成的谁能给你!
#7
http://download.csdn.net/detail/ading_25/3166293
导入数据到excel模板, 读/写。。。自己参考吧,和你说的功能有点出入