最新消息: USBMI致力于为网友们分享Windows、安卓、IOS等主流手机系统相关的资讯以及评测、同时提供相关教程、应用、软件下载等服务。

java通过POI技术将html转成word

业界 admin 12浏览 0评论
private static void inputStreamToWord() throws IOException {
   String content = "<html>" +
      "<head>你好</head>" +
      "<body>" +
      "<table>" +
      "<tr>" +
      "<td>信息1</td>" +
      "<td>信息2</td>" +
      "<td>t3</td>" +
      "<tr>" +
      "</table>" +
      "</body>" +
      "</html>";
   InputStream is = new ByteArrayInputStream(content.getBytes("GBK"));
   OutputStream os = new FileOutputStream("f:\\1.doc");//这里写成自己要输出的路径
   POIFSFileSystem fs = new POIFSFileSystem();
   fs.createDocument(is, "WordDocument");
   fs.writeFilesystem(os);
   os.close();
   is.close();
}
private static void inputStreamToWord() throws IOException {
   String content = "<html>" +
      "<head>你好</head>" +
      "<body>" +
      "<table>" +
      "<tr>" +
      "<td>信息1</td>" +
      "<td>信息2</td>" +
      "<td>t3</td>" +
      "<tr>" +
      "</table>" +
      "</body>" +
      "</html>";
   InputStream is = new ByteArrayInputStream(content.getBytes("GBK"));
   OutputStream os = new FileOutputStream("f:\\1.doc");//这里写成自己要输出的路径
   POIFSFileSystem fs = new POIFSFileSystem();
   fs.createDocument(is, "WordDocument");
   fs.writeFilesystem(os);
   os.close();
   is.close();
}
发布评论

评论列表 (0)

  1. 暂无评论