关闭

JAVA导出EXCEL报告

134人阅读 评论(0) 收藏 举报
//下载评论报告
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();
}
0
0

查看评论
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
    个人资料
    • 访问:30131次
    • 积分:658
    • 等级:
    • 排名:千里之外
    • 原创:76篇
    • 转载:8篇
    • 译文:0篇
    • 评论:0条
    文章分类