如何在打印按钮上将网页表单数据打印到word文件单击 [英] how to print web-form data to word file on Print button Click

查看:98
本文介绍了如何在打印按钮上将网页表单数据打印到word文件单击的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在asp.net中有一个父母反馈webForm,其控件由从数据库中提取的数据进行打包,我想以装饰的Word格式(A4大小)打印它,标题,反馈消息和父母对打印按钮的建议点击。



i有关于它的搜索,但没有得到正确的解决方案。



需要帮助才能完成。

谢谢!

i have a "parents Feedback" webForm in asp.net whose controls are polulated by data fetched from database and i want to print it in decorated Word format(A4 size)with header, feedback messages and suggestions of parent on print button click.

i have googled about it but not getting the proper solution.

need help to do it.
Thanks!

推荐答案

1。无论你想打印什么,只需在网页上显示

2.在网页上,添加一个按钮,说打印

3. OnClick 按钮,写 JavaScript 代码 window.print(); [ ^ ]。
1. Whatever you want to print, just show that on a Web Page.
2. On that Web Page, add a Button saying "Print".
3. OnClick of that Button, write JavaScript code window.print();[^].


所以你要创建一个Word该表格的文件。一种可能的解决方案是在网站中创建一个与表单布局相同的RDLC(本地报表)。然后,当用户结束填写表单并单击打印按钮时,您可以将用户输入的信息作为数据集传递给RDLC报表,这样您就可以在运行时绑定报表,最后使用ReportViewer将其导出为DOC格式太。所以步骤将是:



1.在您的网站(在App_Data文件夹下)创建一个类,并添加与用户必须填写的Web表单中的字段一样多的属性。例如。如果用户提供姓名,年龄等...然后在班级中将其创建为属性



2.创建RDLC报告并选择您在#1创建的班级作为报告的数据来源。然后在RDLC报告中重新创建您的Web表单布局,绑定每个字段的协议



3.在您的aspx webform中,在打印按钮单击中,创建一个新的类实例在#1创建,使用用户输入的值设置属性,创建一个reportviewer实例以加载RDLC报告+将其绑定到刚刚创建的数据对象。使用ReportViewer导出到doc并将其发送回用户(请参阅使用Microsoft Report(RDLC)导出到Word / PDF而不使用报表查看器。 [ ^ ])
So you want to create a Word document of that form. A possible solution is you create a RDLC (local report) in your website with the same layout as your form. Then when the user ends filling the form and click on the Print button, you can pass the info entered by the user to the RDLC report as a data set, so you can bind the report at runtime and finally export it to DOC format using ReportViewer too. So the steps would be:

1. Create a class in your website (under App_Data folder) and add as many properties as fields the user must fill in the web form. E.g. if user provides Name, Age, etc... then create them as Properties in your class

2. Create a RDLC report and select the class you created at #1 as the data source of your report. Then recreate your web form layout in the RDLC report binding each field accord

3. In your aspx webform, in the print button click, create a new instance of the class created at #1, set the properties with the values entered by the user, create a reportviewer instance to load the RDLC report + binding it to the data object you just created. Export to doc using ReportViewer and send it back to the user (refer to Exporting to Word/PDF using Microsoft Report (RDLC) without using Report Viewer.[^])


这篇关于如何在打印按钮上将网页表单数据打印到word文件单击的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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