JAVA导出EXCEL报告
//下载评论报告
public void downloadCommentReport(参数) throws IOException, RowsExceededException, WriteException{
OutputStream out = ServletUtils.currentResponse().getOutputStream();
Map map=commentService.detail(参数);
String user=(String)map.get("screenName");
String time=(String)map.get("time");
List list=(List)map.get("commentList");
ServletUtils.currentResponse().setHeader("Content-disposition","attachment;filename="
+ URLEncoder.encode(user+time+"评论报告.xls", "UTF-8"));
WritableWorkbook workbook=Workbook.createWorkbook(out);
WritableSheet sheet=workbook.createSheet("评论报告", 0);
sheet.addCell(new Label(0,0,"评论ID"));
sheet.addCell(new Label(1,0,"发布日期"));
sheet.addCell(new Label(2,0,"个人ID"));
sheet.addCell(new Label(3,0,"发布内容"));
sheet.addCell(new Label(4,0,"微博ID"));
sheet.addCell(new Label(5,0,"微博链接"));
sheet.addCell(new Label(6,0,"微博内容"));
DateFormat customDateFormat = new DateFormat ("yyyy-MM-dd hh:mm:ss"); 
WritableCellFormat dateFormat = new WritableCellFormat (customDateFormat); 
for(int i=0;i
sheet.addCell(new Label(0,i+1,list.get(i).getId()+""));
sheet.addCell(new DateTime(1,i+1,list.get(i).getCreateAt(),dateFormat));
sheet.addCell(new Label(2,i+1,list.get(i).getUser().getName()));
sheet.addCell(new Label(3,i+1,list.get(i).getText()));
sheet.addCell(new Label(4,i+1,list.get(i).getStatus().getId()+""));
sheet.addCell(new Label(5,i+1,list.get(i).getStatus().getUrl()));
sheet.addCell(new Label(6,i+1,list.get(i).getStatus().getText()));
}
workbook.write();
workbook.close();
}
阅读更多
想对作者说点什么? 我来说一句

java调用ireport生成word报告

2016年02月17日 558KB 下载

没有更多推荐了,返回首页

不良信息举报

JAVA导出EXCEL报告

最多只允许输入30个字

加入CSDN,享受更精准的内容推荐,与500万程序员共同成长!
关闭
关闭