POI导出word文档的基本操作
2014-11-21 14:37
381 查看
XWPFDocument doc = new XWPFDocument(); //创建对象
XWPFParagraph p1 = doc.createParagraph();
p1.setAlignment(ParagraphAlignment.CENTER);
p1.setVerticalAlignment(TextAlignment.TOP);
//创建table
XWPFTable table = doc.createTable(6, 4);
//表格属性
table.setCellMargins(500, 200, 300, 400);
//行数
List<XWPFTableRow> tRows = table.getRows();
//第1行
XWPFTableRow tRow0 = tRows.get(0);
//列数
List<XWPFTableCell> tCell0 = tRow0.getTableCells();
tCell0.get(0).setText("维修单号"); //table 表格赋值
ServletOutputStream out = null;
String wordName = "维修订单.docx";
response.setContentType("application/x-msdownloadoctet-stream;charset=utf-8");
response.setHeader("Content-Disposition", "attachment; filename="+ URLEncoder.encode(wordName, "UTF-8"));
out=response.getOutputStream();
doc.write(out);
out.flush();
out.close();
//生产doc文档 保存
XWPFParagraph p1 = doc.createParagraph();
p1.setAlignment(ParagraphAlignment.CENTER);
p1.setVerticalAlignment(TextAlignment.TOP);
//创建table
XWPFTable table = doc.createTable(6, 4);
//表格属性
table.setCellMargins(500, 200, 300, 400);
//行数
List<XWPFTableRow> tRows = table.getRows();
//第1行
XWPFTableRow tRow0 = tRows.get(0);
//列数
List<XWPFTableCell> tCell0 = tRow0.getTableCells();
tCell0.get(0).setText("维修单号"); //table 表格赋值
ServletOutputStream out = null;
String wordName = "维修订单.docx";
response.setContentType("application/x-msdownloadoctet-stream;charset=utf-8");
response.setHeader("Content-Disposition", "attachment; filename="+ URLEncoder.encode(wordName, "UTF-8"));
out=response.getOutputStream();
doc.write(out);
out.flush();
out.close();
//生产doc文档 保存
相关文章推荐
- POI导出EXCEL经典实现(照着文档操作,1个小时就搞定并且理解了)
- c#操作word文档之简历导出
- POI操作Office导出Html文档
- [POI]Word文档的相关操作
- POI操作WORD文档,生成的新文档为空白文档 -- 待解决
- 利用poi操作word文档(针对docx格式)
- c#操作word文档之简历导出
- poi操作word文档,以07版本为参考,将word文档中图片替换为文本(替换文本也一样),读图片可选文字内容
- apache poi操作office文档---- POI Word DOC格式转Html
- java操作word文档(jacob,poi)
- 使用poi操作word文档实现套打功能
- JAVA不使用POI,用PageOffice动态导出Word文档
- poi操作word文档文件操作
- C#应用程序控制Word文档操作-基本
- 用POI导出Excel的基本操作
- Android项目通过poi操作word文档
- jacob导出word文档操作步骤
- 利用POI操作不同版本word文档中的图片以及创建word文档
- POI导出word 文档
- 【Java工具类】 POI操作word文档模版可修改文字图片