项目需要将富文本内容导出word,
最开始百度,找到poi导出,综合之后 就有了以下代码
public void exportWord(Integer id,HttpServletResponse response) throws Exception {
ByteArrayInputStream bais = null;
OutputStream ostream = response.getOutputStream();
try {
TBrCaseDoc doc = tBrCaseDocMapper.selectByPrimaryKey(id);
String content = "<html><body>"+doc.getContent()+"</body></html>";
bais = new ByteArrayInputStream(content.getBytes("utf-8"));
//生成word
POIFSFileSystem poifs = new POIFSFileSystem();
DirectoryEntry directory = poifs.getRoot();
directory.createDocument("exportWord", bais);
//输出文件
response.setCharact