C#中的单词自动化问题. [英] word automation problem in c#.

查看:126
本文介绍了C#中的单词自动化问题.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在研究单词自动化.我们的系统需要打开Word文件并读取文件内容并将其翻译为另一种语言,然后将每个内容保存在其位置.

我在想,word文件包括纯文本,表格和图片等.我如何知道表格,图片以及纯文本部分的起始位置?

我阅读了有关单词自动化的文章.其中大多数是关于创建文档并插入数据之类的.当我从word文件中读取数据时,它会返回纯文本以及表中的文本.我需要在了解我现在正在阅读的内容的基础上,以不同的方式阅读它们.

我需要做的是:有一个word文件,
首先打开它
然后从头开始读取纯文本(如果开头有纯文本),然后知道表的内容(如果在纯文本部分之后有一个表).简而言之,我需要按顺序读取数据并使它们的内容保存它们的确切位置.
我该怎么办?

让我的问题变得简单.
如果有doc文件,则内容如下:

//doc file-begin
我来自earch.我的名字是汤姆.
tabel1
在我之前和之后都有一张桌子.
table2

//doc文件-结束
如何在不阅读其他部分的情况下阅读第一句话?
我怎么知道我读了第一句话,我将要阅读table1?
然后,在读完表格之后再读第二句话?
当我阅读doc文件时,它返回了文件的全部内容.我需要分开阅读每一部分.
有没有在这件事上有经验的人?请帮忙吗?

有人可以帮我吗?

感谢您的帮助,并等待正确的答案或提示.

I am working on word automation . our system requires open word file and read file content and translate it to another language , then save each content its places.

I am thinking, word file includes pure text , table , and picture so on. how do I know the start position of table, picture as well as pure text section?

I reviewed articles about word automation. most of them about creating document and insert data something like that. when I read data from word file , it return the pure text as well as text in table. I need to read them separate ways with knowing what I am reading now .

what I need to do is : there is a word file ,
first open it
then from the beginning read pure text if there is pure text at beginning, then knowing the content of table if there a table after pure text section. in short I need to read data in sequence and make their content save them exact position.
how could I do that?

let''s make my question simple.
if there is doc file, content like this :

//doc file-begin
I am from earch . my name is tom.
tabel1
there is a table before me and after me.
table2

//doc file - end
how can I read the first sentences without reading other parts?
how can do I know I read the first sentences and I am going to read table1?
then, read the second sentences, after that read table?
when I read doc file it returned the entire content of file. I need to read each part sepearatly.
is there somebody have experience in this matter? pls, help?

could any one help me ?

I thank you for your kind help and wait for right answer or tips

推荐答案

由于您是本主题的新手,所以我不确定您是否确实需要该主题Word自动化,这只是与Word相关的编程的一种方法.最好从这一点开始: http://msdn.microsoft.com/en-us/library/ee342218. aspx [ ^ ].

—SA
As you''re new to the topic, I''m not sure you need exactly Word automation, which is only one approach to Word-related programming. Better start from this point: http://msdn.microsoft.com/en-us/library/ee342218.aspx[^].

—SA


我使用了替换方法,因为我不知道如何保存word文件的格式,因此最好在句子中进行分析平移并替换其翻译中的每个句子.另一个原因是,该解决方案没有可用的解决方案.
I used the replacing methods, since I don''t know how to save the format of word file ,it is better to analys it at sentences level and replace every single sentences by its translation. one more reason is there is no avaiable solution for that perpouse.


每个MS Office产品都有一个对象模型. Word文档中的表不过是类的对象.谷歌一个Word文档的对象模型,您会看到很多的点击...我不知道所有这些.与其他Office产品通话时,我通常通过VBA进行Office自动化,但新的VSTO应该会更好.

我还认为上述SA也提供了一个很好的链接.

祝你好运.
Every MS Office product has an object model. A table in a Word document is nothing more than an object of a class. Google the object model for a Word document and you will see a lot of hits for this...I don''t know all of them off the top of my head. I usually do Office Automation through VBA when speaking to other Office products but the new VSTO is supposed to be better.

I also think that SA above provided a great link to look at as well.

Good luck.


这篇关于C#中的单词自动化问题.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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