日期:2014-05-19 浏览次数:20708 次
public class ExportExcelKmye extends HttpServlet { public ExportExcelKmye() { super(); } public void destroy() { super.destroy(); } public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { doPost(request, response); } public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { try { String exceldate = Tool.getActicleTime().substring(0, 10); String sacct = request.getParameter("sacct"); String eacct = request.getParameter("eacct"); String date = request.getParameter("date"); String state = request.getParameter("state"); response.setContentType("APPLICATION/msexcel;charset=BIG5"); response .setHeader("Content-Disposition", "attachment; filename=" + new String("ヘ緇肂灿.xls".getBytes("BIG5"), "ISO8859_1")); OutputStream os = null; try { os = response.getOutputStream(); } catch (IOException e) { e.printStackTrace(); } WritableWorkbook book = Workbook.createWorkbook(os); WritableSheet sheet = book.createSheet("材", 0); WritableFont headerFont = new WritableFont(WritableFont.ARIAL, 15, WritableFont.BOLD, false, UnderlineStyle.NO_UNDERLINE, jxl.format.Colour.GREEN); WritableCellFormat headerFormat = new WritableCellFormat(headerFont); WritableFont titleFont = new WritableFont(WritableFont.ARIAL, 10, WritableFont.NO_BOLD, false, UnderlineStyle.NO_UNDERLINE, jxl.format.Colour.BLACK); WritableCellFormat titleFormat = new WritableCellFormat(titleFont); WritableFont detFont = new WritableFont(WritableFont.ARIAL, 10, WritableFont.NO_BOLD, false, UnderlineStyle.NO_UNDERLINE, jxl.format.Colour.BLACK); WritableCellFormat detFormat = new WritableCellFormat(detFont); sheet.mergeCells(0, 0, 13, 0);// 虫じ Label lable = new Label( 0, 0, " ヘ緇肂灿 ", headerFormat); sheet.addCell(lable); sheet.mergeCells(0, 1, 11, 0); lable = new Label(0, 1, "ら戳:" + exceldate); sheet.addCell(lable); // ︽糴砞竚 sheet.setColumnView(0, 15); sheet.setColumnView(1, 15); sheet.setColumnView(2, 12); sheet.setColumnView(3, 15); sheet.setColumnView(4, 35); sheet.setColumnView(5, 12); sheet.setColumnView(6, 15); sheet.setColumnView(7,