如何准备一个Word 2007文档,因此C#可以拉数据出来的语义? [英] How to prepare a Word 2007 document so that C# can pull data out of it semantically?

查看:112
本文介绍了如何准备一个Word 2007文档,因此C#可以拉数据出来的语义?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个朋友是谁写的 400页的书在Microsoft Word 2007中。

I have a friend who is writing a 400-page book in Microsoft Word 2007.

纵观他的书 200的故事每一个由许多段落。

Throughout the book he has 200 stories each which consist of numerous paragraphs.

当他写完这本书,他要嵌入在每个故事的文本复制他的Word文档成数据库表如:

When he is finished writing the book, he wants to copy the text of each story that is embedded in his Word document into a database table such as:

Title, varchar(200)
Description, text
Content, text

我们不希望有复制和粘贴每个故事到数据库中,但希望有一个程序从Word自动拉标记的数据文件导入到数据库中的相应字段。

We do not want to have to copy and paste each story into the database but want to have a program automatically pull the marked up data from the Word file into the appropriate fields in the database.


  1. 他有什么在Microsoft Word做的表示每组段落为故事内容和每个标题为故事标题等先决条件的是,这个标记不能在文档中可见。我知道,Word 2007中的文件基本上都是压缩的XML文件,所以我认为这是可能的,我假设的样式是我们所需要的,但我怎么需要精确编写的Word文档,以便为他补充说故事他们得到适当的标记?

  1. What does he have to do in Microsoft Word to denote each group of paragraphs as "story content" and each title as a "story title" etc. A prerequisite is that this markup cannot be visible in the document. I know that Word 2007 files are basically zipped XML files so I assume this is possible and I assume that stylesheets are what we need, but how do I need to prepare the Word document precisely so that as he adds stories they are properly marked up?

我认为新的 COM互操作的C#4.0的功能是什么,我需要分析Word文件,并检索只有标题,描述和内容从嵌入式的故事,但我要如何做到这一点在技术上?有没有人有例子吗?

I assume that the new COM Interop features of C# 4.0 is what I need to analyze the Word file and retrieve only the title, description, and content from the embedded stories, but how do I do this technically? Does anyone have examples?

有没有人有经验做这样一个项目(阅读微软Word作为一个semnatic数据文件),他们可以分享?

推荐答案

我会做的是使用的样式。有一个风格为每种类型的内容,并编写遍历文档段落逐段并吐出相应的文本文件中的宏。

What I would do is use styles. Have one style for each type of content, and write a macro that traverses your document paragraph-by-paragraph and spits out the corresponding text file.

这篇关于如何准备一个Word 2007文档,因此C#可以拉数据出来的语义?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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