Click here to Skip to main content
12,404,895 members (71,609 online)
Rate this:
 
Please Sign up or sign in to vote.
See more: C# C#4.0 RDLC
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!
Posted 1-Aug-12 21:06pm
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 1

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"));
  Permalink  
v5
Comments
rohit24c 2-Aug-12 4:58am
   
its show "An error occurred during local report processing". at 3rd line in your code.
Basically its a rdlc which has subreport and i am having dataset in that rdlc
efkah 2-Aug-12 5:45am
   
Third Line? I would have expected second line, as i said, the lines are to be understood as pseudo-code;-)
try rv.Update() or rv.Show() in between the lines to force the data to be loaded (i editted my solution).
If this doesnt work, look up the Render-Method of the LocalReport:
http://msdn.microsoft.com/en-US/library/ms252172%28v=vs.80%29
I am sorry, i cant help you any further within the next probably 10 hours, and until then i will have forgotten you, so better not expect further help.
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 2

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;
For more ref:
http://beyondrelational.com/modules/24/syndicated/519/posts/12873/sql-server-develop-reports-with-rdlc-aspnet.aspx[^]
  Permalink  
v3

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


Advertise | Privacy | Mobile
Web02 | 2.8.160721.1 | Last Updated 2 Aug 2012
Copyright © CodeProject, 1999-2016
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100