如何以编程方式保存在OpenOffice.org文档? [英] How do I programmatically save a document in OpenOffice.org?
本文介绍了如何以编程方式保存在OpenOffice.org文档?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想通过OpenOffice.org UNO一个 TextDocument
创建保存到磁盘上的文件。什么是做到这一点的最好办法
编辑:这是我最后使用C#代码。 文件
是 XTextDocument
。
保护无效保存(字符串路径)
{
字符串URL =文件://+路径;
为PropertyValue [] propertyValues = {
新为PropertyValue {
NAME =FILTERNAME,
值=新任意(writer8)
}
} ;
((XStorable)文件).storeAsURL(URL,propertyValues);
}
解决方案
使用的 XStorable.storeToURL()(或storeAsURL可)。
编辑:您需要传递 FILTERNAME
的输出格式。示例(Python中因为那更简单):
特性=(为PropertyValue('FILTERNAME',0,'writer8',0 ))
document.storeToURL('文件:///path/to/document.odt',属性)
I'd like to save a TextDocument
created through OpenOffice.org UNO to a file on the disk. What is the best way to do this?
Edit: This is the C# code that I ended up using. document
is an 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);
}
解决方案
Use XStorable.storeToURL() (or storeAsURL).
Edit: You need to pass a FilterName
with the output format. Example (in Python 'cause that's simpler):
properties = ( PropertyValue('FilterName', 0, 'writer8', 0), )
document.storeToURL('file:///path/to/document.odt', properties)
这篇关于如何以编程方式保存在OpenOffice.org文档?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文