如何以编程方式在 OpenOffice.org 中保存文档?

发布于 2024-08-17 19:55:11 字数 473 浏览 4 评论 0原文

我想将通过 OpenOffice.org UNO 创建的 TextDocument 保存到磁盘上的文件中。最好的方法是什么?

编辑:这是我最终使用的 C# 代码。 文档是一个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);
}

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);
}

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

冷弦 2024-08-24 19:55:11

使用 XStorable.storeToURL() (或 storeAsURL)。

编辑:您需要传递带有输出格式的 FilterName 。示例(Python 中,因为这样更简单):

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

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)
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文