1.jsp页面
1 C" d W8 D; u. T) F- G+ r发送请求地址:s9p67_createExcel.do
8 o% m# d& l" h w3 v* [public String createExcel() {
8 s+ A: N, T7 [/ I; G try {( P& m8 F# l+ D$ f& N- e$ E4 {
HttpServletResponse response = ServletActionContext.getResponse();2 q$ @1 ?1 B4 J" u
OutputStream os = response.getOutputStream();; V. c1 ]7 n7 ~' O; P* c c' L8 J
response.reset();
# O8 K. q" g' L& x response.setContentType("application/msexcel;charset=gbk"); //设置响应格式
2 X9 s8 s9 y8 x* _//设置响应头,即报表头
% X1 C" y0 E9 G G! ~ response.setHeader("Content-disposition", "attachment;filename=" + new String("业务受理量统计报表".getBytes(), "iso-8859-1") + ".xls");; A4 ?. I6 Y2 a8 x
HSSFWorkbook hwb = new HSSFWorkbook();* O* Y9 U1 m3 J" O
HSSFSheet sheet = hwb.createSheet("new Sheet");
0 I* h0 n9 d1 W: |& T/ g hwb.setSheetName(0, "业务受理量统计");( l$ e- Z6 J5 x: b( L0 F* L' ]! y
HSSFRow row = sheet.createRow((short) 0);
4 c6 P/ \, s+ P, p2 @+ b sheet.createFreezePane(0, 1);//设置第一行显示内容2 N# U% T! O" d9 u) [5 L+ k2 g( G
createCell(hwb, row, (short) 0, "业务类型");* e0 Y' z+ w$ m) F$ q
createCell(hwb, row, (short) 1, "操作名称");
* f) J) f6 A& m5 n# _+ U9 z- Z createCell(hwb, row, (short) 2, "数量");3 u% h8 d4 i% P
createCell(hwb, row, (short) 3, "收取金额");. w6 w% P* M% M7 e% b0 i
createCell(hwb, row, (short) 4, "工号");) D1 V D" e& w) n
//busBeans列表,为要显示的数据
& O3 P$ i5 h5 l
$ Q. v( s6 K- w) ] Yfor (int i = 1; i |