java怎么由html生成word,保留html样式
@RequestMapping("download")public void exportWord( HttpServletRequest request, HttpServletResponse response) throws Exception {User user = AppContext.getLoginUser(); Student student = studentSvc.findByUserId(user.getId());try {//word内容String content="";byte b[] = content.getBytes("utf-8"); //这里是必须要设置编码的,不然导出中文就会乱码。
ByteArrayInputStream bais = new ByteArrayInputStream(b);//将字节数组包装到流中 /** 关键地方* 生成word格式*/POIFSFileSystem poifs = new POIFSFileSystem(); DirectoryEntry directory = poifs.getRoot(); DocumentEntry documentEntry = directory.createDocument("WordDocument", bais); //输出文件String fileName="实习考核鉴定表";request.setCharac