用jsp程序在服务器端查询数据并且显示出来 点击复选框把选中的数据以excel的格式下载到客户端该怎么解决?希望提供详细的例子程序、先谢谢各位大哥、、、、
解决方案 »
- 我在SSH2配置了两个applicationContext.xml连接两个数据库
- 各位大侠我今天面试被问到一个问题
- 数据库连接错误寻求解答
- 请教LINUX环境下对WAS内的多个App进行资源消耗监控的方法
- log4j的日志——诡异事件
- tomcat的问题 !!!!!!!!!
- 特急!!!!!!!一段提交协议 两段提交协议
- 在转换JAVA应用程序到Java Applet所遇到的问题
- 安装程序的制作问题
- SOS!我在使用JB8时出的问题,
- 在eclipse中导入struts工程时报错
- (100求解)SPRING IOC能否注入值是动态的类?比如向LoginAction注入一个User类,User的值由页面输入来确定
楼主【handongqi415】截止到2008-07-11 12:06:53的历史汇总数据(不包括此帖):
发帖的总数量:0 发帖的总分数:0 每贴平均分数:0
回帖的总数量:0 得分贴总数量:0 回帖的得分率:0%
结贴的总数量:0 结贴的总分数:0
无满意结贴数:0 无满意结贴分:0
未结的帖子数:0 未结的总分数:0
结贴的百分比:---------------------结分的百分比:---------------------
无满意结贴率:---------------------无满意结分率:---------------------
如何结贴请参考这里:http://topic.csdn.net/u/20080501/09/ef7ba1b3-6466-49f6-9d92-36fe6d471dd1.html
有个jxl.jar包
servlet代码:
response.setContentType("application/vnd.ms-excel");
// 生成EXCELL文件流
OutputStream os = response.getOutputStream();
try {
WritableWorkbook workbook = Workbook.createWorkbook(os);
WritableSheet report = workbook.createSheet("报表", 0);
WritableCellFormat alignWay = new WritableCellFormat();
alignWay.setAlignment(jxl.format.Alignment.CENTRE);
// 列标题
int index = 0;
Label id = new Label(index++, 0, "序号", alignWay);
report.addCell(id);
Label acshortname = new Label(index++, 0, "委托客户", alignWay);
report.addCell(acshortname);
Label begincity = new Label(index++, 0, "起始地", alignWay);
report.addCell(begincity);
Label endcity = new Label(index++, 0, "目的地", alignWay);
report.addCell(endcity);
// 数据
if (list != null && list.size() > 0) {
for (int i = 0; i < list.size(); i++) {
BuTransVo vo = (BuTransVo) list.get(i);
int _index = 0;
Number _id = new Number(_index++, i + 1, i + 1, alignWay);
report.addCell(_id);
Label _acshortname = new Label(_index++, i + 1, vo.getacShortName(), alignWay);
report.addCell(_acshortname);
Label _begincity = new Label(_index++, i + 1, vo.gettoBeginC(), alignWay);
report.addCell(_begincity);
Label _endcity = new Label(_index++, i + 1, vo.gettoEndC(), alignWay);
report.addCell(_endcity);
}
}
workbook.write();
workbook.close();
os.flush();
os.close();
} catch (Exception e) { }
request.setAttribute("fileName", reportName);