java导出富文本到word_富文本编辑器内容实现word导出下载,请各位大神们指点,感激不尽...
展開全部
給個我之前的寫的例子給你action?層public?ActionForward?dataExport(ActionMapping?mapping,?ActionForm?form,
HttpServletRequest?request,?HttpServletResponse?response)?{
try?{
response.setContentType("application/vnd.ms-excel;charset=UTF-8");
String?filenames?=?"數據報表32313133353236313431303231363533e78988e69d8331333337383934_"+new?Date().getTime()+".xls";
HttpUtil.setFileNameDownloadHeader(request,?response,?filenames);
OutputStream?os?=?response.getOutputStream();
service.expdataReport(request,?os);
response.flushBuffer();
os.close();
}?catch?(RowsExceededException?e)?{
e.printStackTrace();
}??catch?(WriteException?e)?{
e.printStackTrace();
}?catch?(Exception?e)?{
e.printStackTrace();
}
return?null;
}
service層public?void?expdataReport(HttpServletRequest?request,?OutputStream?os)
throws?IOException,?RowsExceededException,?WriteException?{
String?itemid?=?request.getParameter("itemInfo");
if?(StringUtils.isEmpty(itemid))?{
return;
}
String?hql?=?getZhiJianHql(request);
Map?map?=?new?HashMap();
map.put("itemid",?itemid);
List?list?=?(List)?basedao
.getObjectsByCondtions(ItemReportTemplate.class,?map,?null);
WritableWorkbook?wbook?=?Workbook.createWorkbook(os);?//?工作表
WritableSheet?sheet?=?wbook.createSheet("數據報表",?0);//?生成名為“sheet1”的工作表,參數0表示這是第一頁
WritableFont?times16font?=?new?WritableFont(WritableFont.ARIAL,?10,
WritableFont.BOLD,?false,?UnderlineStyle.NO_UNDERLINE,
Colour.GRAY_50);
WritableCellFormat?times16format?=?new?WritableCellFormat(times16font);?//?字體樣式
ReportUtils.parseExcelHeader(sheet,?times16format,?list);
List?list_c?=?(List)?basedao
.ExcuteHQL(hql.toString());
if?(list_c?!=?null?&&?list_c.size()?>?0)?{
for?(int?j?=?0;?j?
for?(int?i?=?0;?i?
ReportUtils.parseExcelCell(list.get(i),?list_c.get(j),
sheet,?i,?j?+?1);
}
}
}
wbook.write();
wbook.close();
}
總結
以上是生活随笔為你收集整理的java导出富文本到word_富文本编辑器内容实现word导出下载,请各位大神们指点,感激不尽...的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: oracle+行换列,Oracle的数据
- 下一篇: java微博开发_【新手入门篇】新浪微博