Last post Mar 04, 2011 09:33 AM by qwe123kids
Mar 04, 2011 02:10 AM|nidhi.vithlani|LINK
I need to generate word documents using Open Office dlls. I have installed SDK and added reference to all required cli_*.dll. Here is the code that I have implemented:
public static void CreateDoc(string FileName)
XComponentContext oStrap = null;
XMultiServiceFactory oServMan = null;
XComponentLoader oDesk = null;
PropertyValue propVals = null;
XComponent oDoc = null;
oStrap = uno.util.Bootstrap.bootstrap(); //at run-time hanging here
oServMan = (XMultiServiceFactory)oStrap.getServiceManager();
oDesk = (XComponentLoader)oServMan.createInstance("com.sun.star.frame.Desktop");
string url = @"private:factory/swriter";
propVals = new PropertyValue;
oDoc = oDesk.loadComponentFromURL(url, "_blank", 0, propVals);
string docText = "This will be my first paragraph.\n\r";
docText += "This will be my second paragraph.\n\r";
string fileName = @"C:\inetpub\wwwroot\TestOpenOffice\test.odt";
fileName = "file:///" + fileName.Replace(@"\", "/");
catch (System.Exception ex)
oStrap = null;
oServMan = null;
oDesk = null;
propVals = null;
oDoc = null;
The line where I have written comments "at run-time hanging here", the problem is that at run-time, the code is not moving further this line, and thus I am not able to generate document. Some more specifications regarding my problem.
- I am having Windows 7 Ultimate OS
- I am using Visual Studio 2008
- The code is written in 3.5 website (which later on I changed to 2.0 but in vain)
Please let me know if there is any solution to this, as it is kind of urgent. Thanks..
Mar 04, 2011 03:06 AM|qwe123kids|LINK
Better use Openx XMl..
have seen the above link ?
Mar 04, 2011 03:18 AM|nidhi.vithlani|LINK
Thanks for the reply, but actually it is client's requirement to have the documents generated with Open Office and not MS Office.
Is there any mistake in my code itself!
Mar 04, 2011 04:00 AM|qwe123kids|LINK
we have used openXml for Writing Word document as far as i know.
In Open Xml Micorsoft Contributed But Its not properties of Microsft
u may Try Searchin Open Libary Office Libary such as AODL
Mar 04, 2011 06:17 AM|nidhi.vithlani|LINK
One more amazing thing has come up! The dlls and code work perfectly in ASP.NET Web Application, but the same code as stated in my post hangs infinitely in ASP.NET Web Site.
Still I am trying for the same. Thanks..
Mar 04, 2011 09:33 AM|qwe123kids|LINK