简单jxl操作之jsp下载Excel

来源:互联网 发布:mac pro 怎么弹出u盘 编辑:程序博客网 时间:2024/05/17 07:58

upload.jsp

response.setHeader("Content-Disposition", "attachment;filename=" + System.currentTimeMillis() + ".xls");   WritableWorkbook book=Workbook.createWorkbook(response.getOutputStream());      /*WritableCellFormat format=new WritableCellFormat();   format.setBorder(Border.ALL,BorderLineStyle.THIN);   format.setBackground(Colour.GRAY_25);   format.setFont(new WritableFont(WritableFont.createFont("楷体"),14,WritableFont.NO_BOLD,false,UnderlineStyle.DOUBLE));   format.setWrap(true);*/   String[] title={"标题一","标题二","标题三"};      WritableSheet sheet=book.createSheet("test",0);             for(int i=0;i<title.length;i++){   //sheet.setColumnView(i,15);   sheet.addCell(new Label(i,0,title[i]/*,format*/));   }      for(int i=1;i<10;i++){   for(int j=0;j<title.length;j++){   sheet.addCell(new Label(j,i,"数据"/*,format*/));   }   }      book.write();   book.close();   response.flushBuffer();   out.clear();   out=pageContext.pushBody();


index.jsp

<form action="upload.jsp" method="post">  <input type="submit" name="" id="" value="下载" /></form>



0 0
原创粉丝点击