java html转换为word文档
public static boolean writeWordFile() { boolean w = false; String path = "d:/"; try { if (!"".equals(path)) { // 检查目录是否存在 File fileDir = new File(path); if (fileDir.exists()) { // 生成临时文件名称 String fileName = "a.doc"; String content = "<html><div style="text-align: center"><span style="font-size: 28px"><span style="font-family: 黑体">" + "制度发布通知<br /> <br /> </span></span></div></html>"; byte b[] = content.getBytes(); ByteArrayInputStream bais = new ByteArrayInputStream(b); POIFSFileSystem poifs = new POIFSFileSystem(); DirectoryEntry directory = poifs.getRoot(); DocumentEntry documentEntry = directory.createDocument("WordDocument", bais); FileOutputStream ostream = new FileOutputStream(path+ fileName); poifs.writeFilesystem(ostream); bais.close(); ostream.close(); } } } catch (IOException e) { e.printStackTrace(); } return w; }
?