How to programmatically save a document in OpenOffice.org?

I would like to save TextDocumentcreated through OpenOffice.org UNO to a file on disk. What is the best way to do this?

Edit: this is the C # code I used. documentis XTextDocument.

protected void Save (string path)
{
    string url = "file://" + path;
    PropertyValue [] propertyValues = {
        new PropertyValue {
            Name = "FilterName",
            Value = new Any ("writer8")
        }
    };
    ((XStorable) document).storeAsURL (url, propertyValues);
}
+3
source share
1 answer

Use XStorable.storeToURL () (or storeAsURL).

Edit: you need to transfer FilterNamewith the output format. Example (in Python, because it is simpler):

properties = ( PropertyValue('FilterName', 0, 'writer8', 0), )
document.storeToURL('file:///path/to/document.odt', properties)
+2
source

Source: https://habr.com/ru/post/1727668/


All Articles