以编程方式编辑 Microsoft Word 文档 [英] Editing Microsoft Word Documents Programmatically

查看:28
本文介绍了以编程方式编辑 Microsoft Word 文档的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道这是否可以做到.

I want to know if this could be done.

我正在为我们的软件系统(学校项目)构建一个数据字典,我正在考虑一种自动化的方法来做到这一点.基本上我不怎么使用 Microsoft Word (2007),我只用它来记录学校的东西等.我想知道是否可以从模板以编程方式创建/编辑 Word 文档.

I am building a data dictionary for our software system (school project), and I'm thinking of an automated way to do this. Basically I don't use much of Microsoft Word (2007), I only use it in documenting schools stuff, etc. I want to know if its possible to create/edit a Word document programmatically from a template.

这个想法是,我将在 Word 上创建一个页面,其中包含一个将在每个页面上重复的空表单.对于我将输入到我的程序中的每一个数据,它都会更新表单中的相应字段并跳到下一个表单.

The idea is, I will create a page on Word that contains an empty form that will be repeated on every page. For every data that I will input to my program, it will update the corresponding field in the form and skips to the next form.

这样做的目的是消除复制粘贴方法(我的习惯)并在编写文档时加快速度.

The purpose of this, is to eliminate copy-paste methods (my habit) and to speed things up when doing the documentation.

推荐答案

正如其他人所建议的那样,Word 自动化会将您带入一个充满伤害的世界,主要有两个原因:

Word automation, as suggested by others, will lead you to a world of hurt for two major reasons:

  1. Office 并非旨在无人值守的情况下运行,因此它可以随时弹出消息框,并且
  2. 它(可能)未获得许可,无法为没有办公功能的计算机启用办公功能.如果您使用自动化在网站上生成 Word 文档,则必须确保未安装 Office 的计算机无法使用此功能(除非他们在过去几年更改了此规则).

我使用了 Aspose.Words,它的成本有点高,但效果很好,并且是专门为此而设计的.

I have used Aspose.Words, it costs a little, but it works well and is intended for this.

这篇关于以编程方式编辑 Microsoft Word 文档的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆