wordtohtmljava
你可以直接将word文档另存为html文档啊?你所说的java-java是什么东西?
『贰』 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="<html><body></body></html>";
byte b[] = content.getBytes("utf-8"); //这里是必须要设置编码的,不然导出中文就会乱码。
ByteArrayInputStream s = new ByteArrayInputStream(b);//将字节数组包装到流中
/*
* 关键地方
* 生成word格式
*/
POIFSFileSystem poifs = new POIFSFileSystem();
DirectoryEntry directory = poifs.getRoot();
DocumentEntry documentEntry = directory.createDocument("WordDocument", s);
//输出文件
String fileName="实习考核鉴定表";
request.setCharacterEncoding("utf-8");
response.setContentType("application/msword");//导出word格式
response.addHeader("Content-Disposition", "attachment;filename=" +
new String( (fileName + ".doc").getBytes(),
"iso-8859-1"));
OutputStream ostream = response.getOutputStream();
poifs.writeFilesystem(ostream);
s.close();
ostream.close();
}catch(Exception e){
AppUtils.logError("导出出错:%s", e.getMessage());
}
}
『叁』 Java 怎么实现有艺术字的word转成html
1、插入艺术字:插入--文本--艺术字;
2、左键按住艺术字拖动到图片上需要的位置。
『肆』 Java word转html 带有数学公式的word 怎么转换 要能转换公式,html能看见公式,跪求高手解答
在线学习的话应该是B/S模式吧,如果楼主是想将我word内容连同样式一起转换成html有两种方法一种是手动将要上传的word文件另存为html文件,并将html文件传进服务器,由浏览器打开就行另一种是使用控件将要上传的word文件内容转成html代码,现在较好的控件有FCKeditor,eWebEditor,前者免费,后者精简版免费,商业版支持直接上传word文件转成html代码,不过是收费的源码的话真的没有
『伍』 如何java程序将 word转换成html-CSDN论坛
Dispatch wordfile = Dispatch.invoke(
wordacc,
"Open",
Dispatch.Method,
new Object[] { ls_word, new Variant(false),
new Variant(true) }, new int[1]).toDispatch();
Dispatch.invoke(wordfile, "SaveAs", Dispatch.Method, new Object[] {
ls_html, new Variant(8) }, new int[1]);
Variant f = new Variant(false);
// 编写 生成的html
Dispatch.call((Dispatch) wordfile, "Close", (Object) f);
在执行Dispatch.invoke(wordfile, "SaveAs", Dispatch.Method, new Object[] {
ls_html, new Variant(8) }, new int[1]);
jacob.jar
jacob-1.14-x86.dll jacob-1.14-x64.dll 这些的位置有什么要求
抛出异常 路径绝对没有错
com.jacob.com.ComFailException: Invoke of: SaveAs
Source: Microsoft Word
Description: 这不是有效文件名。
请试用下列方法:
* 检查路径,确认键入无误。
* 从文件和文件夹列表中选择文件。
at com.jacob.com.Dispatch.invokev(Native Method)
at com.jacob.com.Dispatch.invokev(Dispatch.java:858)
at com.jacob.com.Dispatch.invoke(Dispatch.java:502)
『陆』 java中的jacob将word文档转化为HTML文件问题
1、到官网下载Jacob,
2、将压缩包解压后,Jacob.jar添加到Libraries中(先复制到项目目录中,右键单击jar包选择Build Path—>Add to Build Path);
3、将Jacob.dll放至当前项目所用到的“jre\bin”下面(比如Eclipse正在用的Jre路径是C:\Java\jdk1.7.0_17\jre\bin)。
Ps:按照上面的步骤配置的,基本没有问题,但是有些电脑可能还会报错,比如:java.lang.UnsatisfiedLinkError: no jacob in java.library.path,这是系统没有加载到jacob.dll,网上解决方法是将Jacob.dll放至“WINDOWS\SYSTEM32”下面。
Java代码:
public class JacobUtil {
// 8 代表word保存成html
public static final int WORD_HTML = 8;
public static void main(String[] args) {
String docfile = "C:\\Users\\无名\\Desktop\\xxx.doc";
String htmlfile = "C:\\Users\\无名\\Desktop\\xxx.html";
JacobUtil.wordToHtml(docfile, htmlfile);
}
/**
* WORD转HTML
* @param docfile WORD文件全路径
* @param htmlfile 转换后HTML存放路径
*/
public static void wordToHtml(String docfile, String htmlfile)
{
// 启动word应用程序(Microsoft Office Word 2003)
ActiveXComponent app = new ActiveXComponent("Word.Application");
System.out.println("*****正在转换...*****");
try
{
// 设置word应用程序不可见
app.setProperty("Visible", new Variant(false));
// documents表示word程序的所有文档窗口,(word是多文档应用程序)
Dispatch docs = app.getProperty("Documents").toDispatch();
// 打开要转换的word文件
Dispatch doc = Dispatch.invoke(
docs,
"Open",
Dispatch.Method,
new Object[] { docfile, new Variant(false),
new Variant(true) }, new int[1]).toDispatch();
// 作为html格式保存到临时文件
Dispatch.invoke(doc, "SaveAs", Dispatch.Method, new Object[] {
htmlfile, new Variant(WORD_HTML) }, new int[1]);
// 关闭word文件
Dispatch.call(doc, "Close", new Variant(false));
}catch (Exception e){
e.printStackTrace();
}finally{
//关闭word应用程序
app.invoke("Quit", new Variant[] {});
}
System.out.println("*****转换完毕********");
}
}
『柒』 linux下java开发work 转html有什么方法
一般安装 LINUX操作系统 都会给你自带上去的 没有的话,也可以通过操作系统的包管理器里进行在线安装 的 输入soffice -headless -accept="socket,host=127.0.0.1,port=8100;urp;" -nofirststartwizard & 提示:soffice: command not found 桌面 的话有菜单 --->办公 --->Openffice.org Writer 你 给的那个错误 提示是说 soffice: command not found 没有找到soffice这个命令,也就是你没有把soffice这个命令加入PATH里, 就像WINDOWS里要把JAVA\BIN加入PATH才能找到执行JAVA的程序 一样我是在命令行里的。我有一个java类实现word2html, 允许后报错:java.net.ConnectException: connection failed: socket,host=localhost,port=8100,tcpNoDelay=1: java.net.ConnectException: Connection refused
『捌』 如何在java中把word转换为html
Dispatch wordfile = Dispatch.invoke(
wordacc,
"Open",
Dispatch.Method,
new Object[] { ls_word, new Variant(false),
new Variant(true) }, new int[1]).toDispatch();
Dispatch.invoke(wordfile, "SaveAs", Dispatch.Method, new Object[] {
ls_html, new Variant(8) }, new int[1]);
Variant f = new Variant(false);
// 编写 生成的html
Dispatch.call((Dispatch) wordfile, "Close", (Object) f);
在执行Dispatch.invoke(wordfile, "SaveAs", Dispatch.Method, new Object[] {
ls_html, new Variant(8) }, new int[1]);
jacob.jar
jacob-1.14-x86.dll jacob-1.14-x64.dll 这些的位置有什么要求
抛出异常 路径绝对没有错
com.jacob.com.ComFailException: Invoke of: SaveAs
Source: Microsoft Word
Description: 这不是有效文件名。
请试用下列方法:
* 检查路径,确认键入无误。
* 从文件和文件夹列表中选择文件。
at com.jacob.com.Dispatch.invokev(Native Method)
at com.jacob.com.Dispatch.invokev(Dispatch.java:858)
at com.jacob.com.Dispatch.invoke(Dispatch.java:502)
『玖』 java有没得框架可以完美的把word转换成html,转换后html里面的图片和样式,与之前word的一样
有
JXL API和java的网页处理API就行了
『拾』 java使用jacob将word转换为html,如何设置转换后html的编码格式。我想要utf-8的,不要gb2312。
强制转码~~
line你要转的内容
line=new String(line.getBytes("gb2312"),"utf-8");代码是我凭记忆写的,应该没问题
或者你在写之前。先写一个HTML页面编码的代码 。把页面的格式设置成utf-8