求助。。。怎么把HTML以WORD格式导出(HTML里包括文字,图片表格等)。。 从来没有这么做过,个人有个想法:在后台读取相关HTML页面的源代码,然后解析。将解析后的结果对应成Word的格式,然后生成Word。 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 import com.jacob.activeX.ActiveXComponent;import com.jacob.com.Dispatch;import com.jacob.com.Variant;public class ExcelToHtml { public static void excelToHtml(String xlsfile, String htmlfile) { ActiveXComponent app = new ActiveXComponent("Excel.Application"); // 启动word try { app.setProperty("Visible", new Variant(false)); Dispatch excels = app.getProperty("Workbooks").toDispatch(); Dispatch excel = Dispatch.invoke( excels, "Open", Dispatch.Method, new Object[] { xlsfile, new Variant(false), new Variant(true) }, new int[1]).toDispatch(); Dispatch.invoke(excel, "SaveAs", Dispatch.Method, new Object[] { htmlfile, new Variant(44) }, new int[1]); Variant f = new Variant(false); Dispatch.call(excel, "Close", f); } catch (Exception e) { e.printStackTrace(); } finally { app.invoke("Quit", new Variant[] {}); } System.out.println("转换成功!"); } public static void main(String[] args) { String paths = new String("I:\\testEXCEL.xls"); String savepaths = new String ("I:\\resultEXCEL.html"); excelToHtml(paths, savepaths); }} 类型的三楼的作用应该可行吧,把xls改为word也类似用poi工具应该也行 你这个不是excel另存为html文件吗?跟楼主的问题有关? iText 可以。先提供图片存放的路径,然后加入到代码中结合文字就可以生成word 过来结贴 问题解决了 呼~ 用的是docx4j包 用jacob之类的插件,应该是可以的以前用过OpenOffice将word转换成html,调用OpenOffice的接口就能搞定或者还有一种思路,就是用word的书签功能,然后通过word插件给书签赋值,包括文本、图片都可以,WebOffice插件可以看看 哥们 我这有个demo 大体用的是docx4j包 邮箱发给我 现在再公司不能发 邮箱 [email protected]小弟也需要啊 求分享 http://blog.sina.com.cn/s/blog_4d7351c10100g1ct.html相关的一个帖子。 小弟也需要啊 求分享邮箱 [email protected]非常需要非常 非常需要 mysql数据库中插入不了数据 N个LIST如何取得交集??? java和javascript tomat6.0.18怎么配置虚拟目录 struts1.x 的validator问题 (请达人帮忙看看。。。) Jsp乱码问题!奇怪拉!!!!!!!!!!!!!!! 请帮我看看这句话的含义 Java程序里访问网报错,急急急! 新人异常:detached entity passed to persist servlet 重定向问题 在js里把一个button设成disable了,然后又取消disable。怎么按钮不变亮呢? extjs 中下拉框可输可选,如何获取输入的值
import com.jacob.activeX.ActiveXComponent;
import com.jacob.com.Dispatch;
import com.jacob.com.Variant;
public class ExcelToHtml {
public static void excelToHtml(String xlsfile, String htmlfile) {
ActiveXComponent app = new ActiveXComponent("Excel.Application"); // 启动word
try {
app.setProperty("Visible", new Variant(false));
Dispatch excels = app.getProperty("Workbooks").toDispatch();
Dispatch excel = Dispatch.invoke(
excels,
"Open",
Dispatch.Method,
new Object[] { xlsfile, new Variant(false),
new Variant(true) }, new int[1]).toDispatch();
Dispatch.invoke(excel, "SaveAs", Dispatch.Method, new Object[] {
htmlfile, new Variant(44) }, new int[1]);
Variant f = new Variant(false);
Dispatch.call(excel, "Close", f);
} catch (Exception e) {
e.printStackTrace();
} finally {
app.invoke("Quit", new Variant[] {});
}
System.out.println("转换成功!");
}
public static void main(String[] args) {
String paths = new String("I:\\testEXCEL.xls");
String savepaths = new String ("I:\\resultEXCEL.html");
excelToHtml(paths, savepaths);
}
}
用poi工具应该也行
小弟也需要啊 求分享
邮箱 [email protected]非常需要
非常 非常需要