用jsp程序在服务器端查询数据并且显示出来 点击复选框把选中的数据以excel的格式下载到客户端该怎么解决?希望提供详细的例子程序、先谢谢各位大哥、、、、
解决方案 »
- 上传文件的问题 文件的内容是正常的 但是上传的文件名传到服务器后就变成了乱码了!!!!
- java上传FTP为什么总是返回false?
- 关于socket
- 如何隐藏WEB-INF目录外的JSP页面
- Hibernate 执行原生SQL为什么只能返回指定字段的第一个字符?
- Servlet出错
- springMVC 跳转不到jsp,求解
- log4j 中的级别!
- 我这样设置我得web应用程序对吗?我遇到问题了,tomcat4.1~上
- oracle数据库,不用触发器,如何用JAVA程序来实现主键的增长
- 在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);