码迷,mamicode.com
首页 > 其他好文 > 详细

jxl实现的导出excel的功能

时间:2014-07-16 13:11:41      阅读:268      评论:0      收藏:0      [点我收藏+]

标签:java-excel导出

<%@ page language="java" import="java.util.*" pageEncoding="GBK"%>

<%@ page import="jxl.Workbook"%>

<%@ page import="jxl.format.Alignment"%>

<%@ page import="jxl.format.Border"%>

<%@ page import="jxl.format.BorderLineStyle"%>

<%@ page import="jxl.format.Colour"%>

<%@ page import="jxl.format.UnderlineStyle"%>


<%@ page import="jxl.write.Label"%>

<%@ page import="jxl.write.WritableCellFormat"%>

<%@ page import="jxl.write.WritableFont"%>

<%@ page import="jxl.write.WritableSheet"%>

<%@ page import="jxl.write.WritableWorkbook"%>

<%@ page import="jxl.write.WriteException"%>

<%

response.reset();

response.addHeader("Content-Disposition", "attachment;filename="+new String("1.xls".getBytes("GB2312"),"ISO8859-1"));

WritableWorkbook wwb = Workbook.createWorkbook(response.getOutputStream());

WritableSheet ws = wwb.createSheet("报表", 0);

int[] colsWidth = new int[2];

WritableFont wfc = new WritableFont(WritableFont.ARIAL, 10, WritableFont.BOLD,false,UnderlineStyle.NO_UNDERLINE,Colour.BLUE);

WritableCellFormat wcfFC = new WritableCellFormat(wfc);

wcfFC.setAlignment(Alignment.CENTRE);

wcfFC.setBorder(Border.ALL, BorderLineStyle.THIN);

Label heaLabel = new Label(0,0,"id",wcfFC);

ws.addCell(heaLabel);

heaLabel = new Label(1,0,"name",wcfFC);

ws.addCell(heaLabel);

heaLabel = new Label(0,1,"1",wcfFC);

ws.addCell(heaLabel);

heaLabel = new Label(1,1,"1",wcfFC);

ws.addCell(heaLabel);

wwb.write();

wwb.close();

out.clear();

out = pageContext.pushBody();

%>

简单的实现留作以后如果忘记了还可以再看看

jxl实现的导出excel的功能,布布扣,bubuko.com

jxl实现的导出excel的功能

标签:java-excel导出

原文地址:http://4449493.blog.51cto.com/4439493/1438893

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!