简体   繁体   English

通过开放式办公室以编程方式创建 Word 文档

[英]Programmatically creating word document via open office

I am looking to do a mail merge in Word using their interop libraries.我希望使用他们的互操作库在 Word 中进行邮件合并。 However having issues getting word installed on my developer machine due to IT at work.但是,由于 IT 在工作,在我的开发人员机器上安装 word 时遇到问题。

Is it possible to programmatically interact with OpenOffice as an alternative?作为替代方案,是否可以以编程方式与 OpenOffice 交互? Ideally in C#理想情况下在 C#

There are a handful of third-party C# libraries that can do this, such as OfficeWriter (who I work for) and others.有一些第三方 C# 库可以做到这一点,例如OfficeWriter (我为之工作)等。

Using the library and your Word document you simply call a method, passing in the data to be mail merged.使用库和您的 Word 文档,您只需调用一个方法,传入要进行邮件合并的数据。 The API is usually pretty strait forward: API 通常非常严格:

using (WordTemplate wordTemplate = new WordTemplate())
{
    wordTemplate.Open("YourFilePath.docx");

    // yourData is a a DataTable in this case, 
    // but SetDataSource has many overloads
    wordTemplate.SetDataSource(yourData);

    wordTemplate.Process();

    wordTemplate.Save("OutputFilePath.docx");
}

Microsoft provides a development platform for handling Word (.docx), Excel (.xlsx) and PowerPoint (.pptx) files without installing the softwares. Microsoft 提供了一个无需安装软件即可处理 Word (.docx)、Excel (.xlsx) 和 PowerPoint (.pptx) 文件的开发平台。 The feature is avaliable like a SDK.该功能像 SDK 一样可用。

Look this: http://msdn.microsoft.com/en-us/office/bb265236.aspx看看这个: http : //msdn.microsoft.com/en-us/office/bb265236.aspx

If you wanna more help, please try something and post.如果您需要更多帮助,请尝试并发布。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM