如何使用 windows-rs rust crate 编辑 Word 文档?

问题描述 投票:0回答:0

我使用 python pywin32 包开发了一些代码以将引用插入 Microsoft Word,虽然它确实有效,但我想将此代码转换为更紧凑和高效的 Rust 可执行文件。我看到 windows-rs crate 似乎与 pywin32 python 包相似,但在与 Microsoft office 文件和文档进行交互时我没有看到很多相似之处。有没有我遗漏的文件?如果没有,任何具有该领域专业知识的人都可以指出最合适的功能,以便我可以使用它吗?如果您有兴趣阅读我的 python 代码,请访问以下 github 链接:https://github.com/ryandikdan/InCite 插入引文的示例显示在此代码片段中

import win32com.client as win32

def add_citation(xml_string):
    # Select Microsoft Word
    word = win32.GetActiveObject("Word.Application")
    # Select the active document (not sure if this will work if multiple files are open, but one is in front? could specify a specific file in the future with:
    # doc = wordapp.Documents.Open(r"C:\\temp\\testing.docx")
    doc = word.ActiveDocument
    # Adds the formatted xml from the other functions to the document, which should also add it to the master list I think.
    doc.Bibliography.Sources.Add(xml_string)

我没能在文档中找到任何合适的功能: https://microsoft.github.io/windows-docs-rs/doc/windows/index.html

此外,doc.rs 上的页面似乎选项较少: https://docs.rs/windows/latest/windows/index.html

windows rust com windows-runtime
© www.soinside.com 2019 - 2024. All rights reserved.