如何以编程方式创建带有内容控件的word文档并循环访问这些控件? [英] how can I programmatically create a word document with content controls and loop through those controls?

查看:119
本文介绍了如何以编程方式创建带有内容控件的word文档并循环访问这些控件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,



我有一个要求,我需要以编程方式从ASP.net应用程序创建word文档。主要是word文档会有一组问题,每个问题后面应该跟一个空的内容控件Textbox。



用户将回答这些问题,然后必须再次上传文档,然后我必须以编程方式遍历文档以获得答案并将其保存到数据库。



如何实现?创建带有空内容控件的word文档,并在用户回答问题后循环遍历文档以获取内容控件中的文本

Hi Everyone,

I have a requirement from which i need to programmatically create a word document from ASP.net application. Mainly the word document will have set of questions, each question should be followed by an empty content control "Textbox".

The user is going to answer those questions, then have to upload the document again,then i have to loop through the document programmatically to get the answers out and save it to database.

how can this be implemented?? the creation of word document with an empty content controls and also looping through the document to get the text inside the content controls after the user answer the questions

推荐答案

请参阅我的过去的回答:

将Office文档转换为PDF而不互操作 [ ^ ],

你好我怎么能使用c#.net 在Windows应用程序中显示word文件[ ^ ],

在不使用Interop.word dll的情况下读取word文件...不想在IIS中安装单词。 [ ^ ]。



如果相关,则不是全部,但你可以找到一些基本的想法。



另外,请看这篇精彩的CodeProject文章:您将使用的专业HTML渲染器 [ ^ ]。



即使这样工作与Word没有任何关系,如果你看一下实现,你可能会发现你的部分工作已经完成。这个奇妙的组件将HTML呈现为RTF。但RTF与Microsoft Word兼容,如果您使用Word自动化,它总是可以使用RTF数据创建Word文档(我解释了如何使用 Microsoft.Office.Interop 在我上面提到的答案中)。还有一个想法,你可以尝试考虑。



-SA
Please see my past answers:
Convert Office-Documents to PDF without interop[^],
Hi how can i display word file in windows application using c#.net[^],
Read a word file without using Interop.word dll...Do not want to install word in IIS..[^].

Not all if it is relevant, but you can find some basic ideas.

Also, please see this wonderful CodeProject article: A Professional HTML Renderer You Will Use[^].

Even though this work does not have anything to do with Word, if you look at the implementation, you may find that part of your work is already done. This wonderful component renders HTML as RTF. But RTF is something compatible with Microsoft Word, which can always use RTF data to create a Word document, if you use Word automation (I explained how to use Microsoft.Office.Interop in my answers referenced above). Just yet another idea you can try to consider.

—SA


这篇关于如何以编程方式创建带有内容控件的word文档并循环访问这些控件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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