在后台创建报告 [英] create report in background
本文介绍了在后台创建报告的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
你好,
我有一个Winform应用程序,在其中单击按钮时,我现在有2个单独的rdlc.我需要在没有reportViewer的情况下生成报告,并将报告另存为2个单独的.pdf文件.
请提供任何建议!
Hello,
I have a Winform Application in which i have 2 separate rdlc''s now on click of button i need generate the report with out reportViewer and to save the report as 2 separate .pdf files.
Any suggestions please!
推荐答案
对不起,我无法复制和粘贴代码,但是我以前做过,据我所记得,这非常容易.
1.)初始化ReportViewer
2.)设置LocalReport-Path
3.)使用导出将其保存到磁盘
代码应遵循以下原则:
sorry i cannot copy and paste code, but i have done this before, its very easy as far as i remember.
1.) Initialize ReportViewer
2.) Set the LocalReport-Path
3.) Use the Export to save it to disk
Code should be something along those lines:
ReportViewer rv = new ReportViewer();
rv.LocalReport.ReportPath = @"resources\test.rdlc";
rv.RefreshReport();
File.WriteAllBytes(@"c:\my.pdf", rv.LocalReport.Render("PDF"));
嗨
请尝试这个
hi
Please try this
<rsweb:ReportViewer ID="Report1" runat="server" Font-Names="Verdana" Font-Size="8pt"
Height="515px" Width="100%" ShowExportControls="true" SizeToReportContent="False" >
<LocalReport ReportPath="Rdlc\reports1.rdlc" EnableHyperlinks="True">
<DataSources>
<rsweb:ReportDataSource DataSourceId="ObjectDataSource1" Name="reports1_reports1" />
</DataSources>
</LocalReport>
</rsweb:ReportViewer>
<asp:ObjectDataSource ID="ObjectDataSource1" runat="server" SelectMethod="GetData"
TypeName="ReportTableAdapters."></asp:ObjectDataSource>
//后面的代码
//Code behind
ReportDataSource datasource = new
ReportDataSource("reports1_reports1",
dtViewInfo);
Report1.LocalReport.DataSources.Clear();
Report1.LocalReport.DataSources.Add(datasource);
Report1.LocalReport.Refresh();
Report1.Visible = true;
有关更多参考:
http://beyondrelational.com/modules/24/syndicated/519/posts/12873/sql-server-develop-reports-with-rdlc-aspnet.aspx [
For more ref:
http://beyondrelational.com/modules/24/syndicated/519/posts/12873/sql-server-develop-reports-with-rdlc-aspnet.aspx[^]
这篇关于在后台创建报告的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文