??????? List<PhoneLogDto> list=new ArrayList<T>(); //换成数据源
??? ??? response.setContentType("application/msexcel");
??? ??? response.setHeader("Content-disposition", "attachment; filename=name.xls");// 设定输出文件名称
??? ??? OutputStream os = response.getOutputStream();
??? ??? WritableWorkbook wwb = Workbook.createWorkbook(os);//创建可写工作薄??
??? ??? WritableSheet ws = wwb.createSheet("sheet1", 0);//创建可写工作表
??? ??? ws.addCell(new Label(0,0,"列名1"));//列数随你控制
??? ??? ws.addCell(new Label(1,0,"列名2"));
??? ??? ws.addCell(new Label(2,0,"列名3"));
??? ??? ws.addCell(new Label(3,0,"列名4"));
??? ??? ws.addCell(new Label(4,0,"列名5"));
??? ??? ws.addCell(new Label(5,0,"列名6"));
??? ??? ws.addCell(new Label(6,0,"列名7"));
??? ??? int i=1;
??? ??? for(T obj:list){
??? ??? ??? ws.addCell(new Label(0,i,obj.getName()));//此处obj是个对象
??? ??? ??? ws.addCell(new Label(1,i,obj.getName()));
??? ??? ??? ws.addCell(new Label(2,i,obj.getName()));
??? ??? ??? ws.addCell(new Label(3,i,obj.getName()));
??? ??? ??? ws.addCell(new Label(4,i,obj.getName()));
??? ??? ??? ws.addCell(new Label(5,i,obj.getName()));
??? ??? ??? ws.addCell(new Label(6,i,obj.getName()));
??? ??? ??? i++;
??? ??? }
??? ??? //现在可以写了??
??? ??? wwb.write();
??? ??? //写完后关闭??
??? ??? wwb.close();
??? ??? //输出流也关闭吧??
??? ??? os.close();