阅读和C#.NET替换.doc文件的文本 [英] Read and replace texts of .doc file in c#.net

查看:110
本文介绍了阅读和C#.NET替换.doc文件的文本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我工作的项目,需要读取客户端提供的.doc文件。它需要替换一些文本在并再次保存,让用户可以有自己的数据文件。

I am working on project which needs to read .doc file given by client. It needs to replace some text in that and save again, so user can have that file with their own data.

即。我们通常做的同时将邮件发送到客户端读取参数。 (只是一个例子)

i.e. we normally do parameters read while sending mail to client. (just an example)

我看了一些帖子它,它需要MS字要在服务器上安装。有没有办法做到不MS字DLL我的要求

I have read some post about it and it needs MS word to be install on server. Is there a way to do my requirements without MS word dll

我试图将该文件转换以.htm和读课文,并取代它,但是我需要在.htm文件转换回.doc文件的最后一件事。当我这样做手工所有水印的文字和标志等不在新的.doc文件。所以这是没有用的我。

I tried to convert that file in .htm and read the text and replace it however the final thing i need to convert that .htm file back to .doc file. when i do that manually all the watermark text and logos etc are not in the new .doc file. So that is useless for me.

任何人都可以请建议我,我可以尝试和前进的方式。

Can anyone please suggest me the way I can try and go ahead.

在此先感谢

推荐答案

在R&安培花费几个小时后; D,最后我得到了,我喜欢张贴此作为答案,所以每个人都可以使用

After spending some hours on R&D, at last I got, I like to post this as answer,so everyone can use.

我的问题,我发现正是合适的解决办法:)

The exactly suitable answer for my question i found :)

感谢codePLEX

只要下载该应用程序,并采取适合自己的功能。在我的情况....

Just download the application and take your suitable function. In my case....

 Console.WriteLine("\tReplaceTextParallel()\n");

    DocX document = DocX.Load("D:\\mytest.docx");
    document.ReplaceText("{@adress12345}", "This is my new address for between");

    // Directory containing many .docx documents.

    document.Save();


    Console.WriteLine("\tCreated: None\n");

真的很简单。

这篇关于阅读和C#.NET替换.doc文件的文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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