开发者

use C# code in Java

I have a code in C# that I need to use or convert in Java. It is a code that use a Reference to t开发者_JAVA百科he Word 12.0 Object Library.

Here the beginning the C# code :

using System; using System.Collections.Generic; using System.Linq; using System.Text; using Microsoft.Office.Interop.Word; How can I use C# in Java or how can I rewrite the code withe the reference from C# to Java?

Thank you


Apache POI - the Java API for Microsoft Documents:

The Apache POI Project's mission is to create and maintain Java APIs for manipulating various file formats based upon the Office Open XML standards (OOXML) and Microsoft's OLE 2 Compound Document format (OLE2). In short, you can read and write MS Excel files using Java. In addition, you can read and write MS Word and MS PowerPoint files using Java. Apache POI is your Java Excel solution (for Excel 97-2008).


To convert the code you can use the converter mentioned by slandau. You can use a number of solutions for Word interop. Apache POI is one. OpenOffice is another. docx4j is another.

The good thing about those solutions is you will not need to install Microsoft Word to use them (unlike your existing interop code in C#). You could also use JACOB and COM if you wanted to use MS Word directly.

If you want to keep it simple and use your C# code, you might be better off writing a console application in C# and passing parameters to it using Java (or you can write a web service, although Word interop in a web service gets tricky).


You could use a tool such as http://www.cs2j.com/,

However I would recommend you learn the differences between C# and Java, and re-write the library yourself - or look for a similar one that already exists, PLEASE.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜