I'm a newbie developer who develop a software for a company, although I am quite familiar with programming I rarely develop a software for a company, now after I join a company I started to get a problem creating a software.
I must develop a software that can be installed and updated on client computer easily, I solve this by using clickonce, then the problem arise, nearly all software I develop must have report viewer, I try using reportviewer from microsoft, but this give me more problem when installing, I try everything I found on the web to make a setup that easy to install, but I keep struggle when installing reportviewer, it keeps error on some computer although sometimes it install without error on other computer.
I need a suggestion how I can develope a program that can display a report and print it without install any other program on the client. I use C# on Visual Studio 2015, I develop WPF, and web using it.
Use nuget in your project and add the following dependencies to it
Microsoft.ReportViewer.2015.Runtime
Microsoft.ReportViewer.VS2015.WinForms
Launch your report viewer like this:
var dlg = new ReportPreviewDialog();
dlg.ReportViewer.LocalReport.DisplayName = "My report";
dlg.ReportViewer.LocalReport.DataSources.Add(new ReportDataSource("datasource1", data));
dlg.ReportViewer.LocalReport.DataSources.Add(new ReportDataSource("datasource2", data2));
dlg.ReportViewer.LocalReport.ReportEmbeddedResource = "YourClient.TheReport.rdlc";
dlg.ShowDialog();
TheReport.rdlc
is your report as resource in your project (=> Build Action: Embedded Resource). Make sure the namespace is correct or your report won't be found.
Works with WPF.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With