7

Note: I found this "Creating a Word Doc in C#.NET", but that is not what I want.

Do you know how to create a .odt to create file from C# .NET?
Is there a .NET component or wrapper for an OpenOffice.org library to do this?

4

6 回答 6

3

Have a look at AODL (see http://odftoolkit.org/projects/odftoolkit/pages/AODL).

  • fully managed .NET 1.1 (so it runs on MS.Net and Mono)
  • support for text and spreadsheet documents
  • create, read, edit, save documents
  • ...

EDIT by kame: New link AODL-Wiki

于 2009-01-05T20:13:27.450 回答
2

You can check out the OASIS Standards site for information on the ODT standard. From what I've seen, they're using an XML based standard and have an XSD available for the the document standard, so you could use that in conjunction with your own code to build a document file in the proper format.

于 2008-10-21T22:43:50.470 回答
2

You might be interested in OpenOffice, UNO CLI Language Binding.

于 2008-10-21T23:21:35.200 回答
1

I found this one yesterday when looking for a way to create Spreadsheeets, it looks like creating writer files is quite similar: http://www.suite101.com/content/creating-an-openoffice-calc-document-with-c-a124112, dont forget to install the Open Office SDK from Oracle first.

Unfortunately I have not found a way to create a file without opening it yet.

于 2011-01-20T03:28:47.237 回答
0

The code would look like this:

private XComponentContext oStrap = uno.util.Bootstrap.bootstrap();
XMultiServiceFactory oServMan = (XmultiServiceFactory) oStrap.getServiceManager();
XComponentLoader oDesk = (XComponentLoader) oServMan.createInstance("com.sun.star.frame.Desktop");
string url = @"private:factory/swriter";
PropertyValue[] propVals = new PropertyValue[0];
XComponent oDoc = oDesk.loadComponentFromURL(url, "_blank", 0, propVals);
string docText = "File Content\n\r";
((XTextDocument)oDoc).getText().setString(docText);
string fileName = @"C:\FolderName\FileName.odt";
fileName = "file:///" + fileName.Replace(@"\", "/");
((XStorable)oDoc).storeAsURL(fileName, propVals);
((Xcomponent)oDoc).dispose();
于 2013-04-02T11:55:15.043 回答
0

OpenOffice documents (odt) are ZIP files. You can unzip an existing one, modify the content.xml file by code and then use the ZipFile class from System.IO.Compression for example to get a zip file again. Open Office Specification

于 2018-02-06T01:32:56.463 回答