选择性导出Excel文档
来源:互联网 发布:一组数据的range怎么求 编辑:程序博客网 时间:2024/04/28 05:30
选择性导出Excel文档
记录者:
张守伟[Feg.soft]
导出过程:
此过程经过三个文件:
1、 exportExcel.jsp(选择导出字段,只是用来判断导出哪些字段的内容,不涉及查询数据库)
<%@ page language="java" contentType="text/html; charset=GB18030"
pageEncoding="GB18030"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=GB18030">
<title>导出Excel测试</title>
<script type="text/javascript" src="../util/javascript/jquery.js"></script>
<script type="text/javascript">
$(function() {
//全选
$("#selectall").click(function() {
$("input[@id='selectFlag']").each(function() {
$(this).attr("checked", true);
});
});
//反选
$("#fanall").click(function() {
$("input[@id='selectFlag']").each(function() {
if($(this).attr("checked"))
{
$(this).attr("checked", false);
}
else
{
$(this).attr("checked", true);
}
});
});
//取消全部
$("#deselectall").click(function() {
$("input[@id='selectFlag']").each(function() {
$(this).attr("checked", false);
});
});
2、 ExportExcelActionForm.java(收集选择的字段)
package org.feg.gims.test;
import org.apache.struts.action.ActionForm;
public class ExportExcelActionForm extends ActionForm {
private String id;
private String flpCount;
private String flpPassword;
private String flpName;
private String idcard;
private String sex;
private String subject;
private String city;
private String school;
private String telphone;
private String qq;
private String email;
public String getId() { return id; }
public void setId(String id) { this.id = id; }
public String getFlpCount() { return flpCount; }
public void setFlpCount(String flpCount) {this.flpCount = flpCount; }
public String getFlpPassword() { return flpPassword; }
public void setFlpPassword(String flpPassword){this.flpPassword=flpPassword;}
public String getFlpName() { return flpName; }
public void setFlpName(String flpName) { this.flpName = flpName; }
public String getSex() { return sex; }
public void setSex(String sex) { this.sex = sex; }
public String getSubject() { return subject; }
public void setSubject(String subject) { this.subject = subject; }
public String getCity() { return city; }
public void setCity(String city) { this.city = city; }
public String getSchool() { return school; }
public void setSchool(String school) { this.school = school; }
public String getTelphone() { return telphone; }
public void setTelphone(String telphone) {this.telphone = telphone;}
public String getQq() { return qq; }
public void setQq(String qq) { this.qq = qq; }
public String getEmail() { return email; }
public void setEmail(String email) { this.email = email; }
public String getIdcard() { return idcard; }
public void setIdcard(String idcard) { this.idcard = idcard;}
}
3、 ExportExcelAction.java(执行数据库查询[将所有字段都取出]和导出过程)
// 写入数据
book.write();
System.out.println("Excel导出成功!");
} catch (WriteException e) {
System.out.println("写入Excel出错!!" + e);
} catch (IOException e) {
System.out.println("导出Excel出错!!" + e);
} finally {
try {
if (book != null) {
// 关闭文件
book.close();
book = null;
}
} catch (WriteException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
}
}
- 选择性导出Excel文档
- GridView选择性导出Excel
- java 选择性导出excel表格
- FarPoint导出excel文档
- JSP导出Excel文档
- Struts 导出 Excel 文档
- POI导出Excel文档
- POI导出EXCEL文档
- java导出Excel文档
- extjs导出Excel文档
- Vertx_web导出excel文档
- 导出excel 文档1
- 导出excel文档2
- 导出excel文档
- POI 导出Excel文档
- asp导出Excel文档代码
- asp导出Excel文档代码
- ASP导出到Excel文档
- 使用jsp导出到excel汇总
- Ubuntu 10.10 安装谷歌PinYin拼音输入法
- Proguard混淆器Android
- Struts2 标签库、树形结构资料大全
- Cocoa框架类之间继承关系
- 选择性导出Excel文档
- hosts文件
- java读sftp
- 小记Matlab与C#混合编程
- 优化问题关于const第二篇
- Android 图书总汇
- 用 Java 实现断点续传 (HTTP)
- Android的关机调试步骤记录
- 玩LFS的几个有用脚本