Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the best way to display report without installing anything on client

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.

like image 308
iha Avatar asked Mar 13 '23 10:03

iha


1 Answers

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.

like image 169
BlueM Avatar answered Apr 25 '23 21:04

BlueM