jxl导出excel

          导出不成功,页面显示乱码问题

          //导出
         response.setCharacterEncoding("UTF-8");
         //导出excel
         response.reset();
         response.setHeader("Content-Disposition","attachment;filename=" +new String( ("知识录入批量导出" + ".xls").getBytes(),"iso-8859-1"));
         response.setContentType("application/msexcel");

			//excel和sheet名字
			String name=Integer.valueOf("2012")
						+ "年"
						+ "9"+ "月知识增长数量";
			//导出excel
			response.reset();
			response.setHeader("Content-Disposition",
                     "attachment;filename=" +
                     new String( (name + ".xls").getBytes(),
                                "iso-8859-1"));
			response.setContentType("application/msexcel");
			OutputStream os = response.getOutputStream(); 
			//创建工作单元
			WritableWorkbook wb=Workbook.createWorkbook(os);
			WritableSheet sheet = wb.createSheet(name, 0);
			//向excel中写入数据,一级分类、二级分类、知识分类、知识类型、标题、浏览量
			//标题格式
			WritableFont font = new WritableFont(WritableFont.ARIAL,10,WritableFont.BOLD);
			WritableCellFormat format = new WritableCellFormat(font);
			//标题
			Label title0=new Label(0,0,"日期",format);
			Label title1=new Label(1,0,"知识增长数量",format);
			sheet.addCell(title0);
			sheet.addCell(title1);
			wb.write();
			wb.close();
			os.close();


 

你可能感兴趣的:(Excel,JXL)