xml文件用什么软件转换成word

有没有人在啊,想请问下,xml文件用什么软件转换成word
最新回答
祁梦

2024-05-01 01:48:54

通过jodconveter来实现转化。这种方式实现起来比较麻烦,操作有点繁琐,但是能解决上述问题。通过启动OpenOffice.org的服务端口,实现程序操作opeanoffice实现文件的转换。
贴上代码:
mport
java.io.File;
import
java.io.FileInputStream;
import
java.io.FileOutputStream;
import
java.io.InputStream;
import
java.io.OutputStream;
import
com.artofsolving.jodconverter.DefaultDocumentFormatRegistry;
import
com.artofsolving.jodconverter.DocumentConverter;
import
com.artofsolving.jodconverter.DocumentFormatRegistry;
import
com.artofsolving.jodconverter.openoffice.connection.OpenOfficeConnection;
import
com.artofsolving.jodconverter.openoffice.connection.SocketOpenOfficeConnection;
import
com.artofsolving.jodconverter.openoffice.converter.OpenOfficeDocumentConverter;
public
class
test
{
/**
*
@param
args
*/
public
static
void
main(String[]
args)
throws
Exception
{
//
TODO
Auto-generated
method
stub
test
t
=
new
test();
//File
in
=
new
File("d:\\mytest\\test1.pdf");
//File
out
=
new
File("d:\\mytest\\test11.html");
FileInputStream
input
=
new
FileInputStream("d:\\mytest\\test11.pdf");
FileOutputStream
output
=
new
FileOutputStream("d:\\mytest\\test11.doc");
t.convert(input,
output);
}
public
void
convert(File
input,
File
output)
throws
Exception
{
OpenOfficeConnection
conn
=
new
SocketOpenOfficeConnection("localhost",
8100);
conn.connect();
DocumentConverter
converter
=
new
OpenOfficeDocumentConverter(conn);
converter.convert(input,
output);
conn.disconnect();
}
public
void
convert(InputStream
input,
OutputStream
output)
throws
Exception
{
OpenOfficeConnection
conn
=
new
SocketOpenOfficeConnection("localhost",
8100);
conn.connect();
DocumentConverter
converter
=
new
OpenOfficeDocumentConverter(conn);
DocumentFormatRegistry
registry
=
new
DefaultDocumentFormatRegistry();
converter.convert(input,
registry.getFormatByFileExtension("pdf"),
output,
registry.getFormatByFileExtension("doc"));
conn.disconnect();
}
}