I have two report rdlc in my c# application, I want to print both of them when click button.
Here is my code:
private void btnPrint_Click(object sender, EventArgs e)
{
LocalReport report1 = new LocalReport();
report1.ReportPath = Application.StartupPath + "\\Report1.rdlc";
report1.PrintToPrinter();
LocalReport report2 = new LocalReport();
report2.ReportPath = Application.StartupPath + "\\Report2.rdlc";
report2.PrintToPrinter();
}
the code print the first report1.rdlc but the second report2.rdlc not printed. How can I fix this thanks ?
This is my references : https://foxlearn.com/windows-forms/how-to-print-rdlc-report-without-report-viewer-in-csharp-410.html
Related
I connect to Report Server with an application and run an rdl report in Report Viewer ,
now Question ?
How can I send the report to the printer automatically in Report Viewer?
Thank All of you
private void Form1_Load(object sender, EventArgs e)
{
// Set the processing mode for the ReportViewer to Remote
reportViewer1.ProcessingMode = ProcessingMode.Remote;
reportViewer1.ServerReport.ReportServerUrl = new Uri("http://Server/reportserver");
reportViewer1.ServerReport.ReportPath = #"/Customereport/rms3invoice";
reportViewer1.ServerReport.ReportServerCredentials.SetFormsCredentials(
null, "Admin","admin", null);
ReportParameter reportParameter = new ReportParameter();
reportParameter.Name = "ID";
reportParameter.Values.Add("2");
// reportParameter.Values.Add("3");
reportViewer1.ServerReport.SetParameters(new ReportParameter[] { reportParameter });
this.reportViewer1.RefreshReport();
// reportViewer1.Print += ReportViewer1_Print;
}
When i run this on VS it works fine but when i run it on another computer it cant find the RDLC path.
private void button1_Click(object sender, EventArgs e)
{
LocalReport localReport = new LocalReport();
ReportParameterCollection reportParameters = new ReportParameterCollection();
reportParameters.Add(new ReportParameter("Pallet_label", lb_pallet_name.Text));
reportParameters.Add(new ReportParameter("Par_PalNum", LB_Number.Text));
localReport.ReportPath = Application.StartupPath + "\\pallet_label.rdlc";
localReport.SetParameters(reportParameters);
localReport.PrintToPrinter();
}
It will print the report but wont add the report Parameters
private void button1_Click(object sender, EventArgs e)
{
ReportParameterCollection reportParameters = new ReportParameterCollection();
reportParameters.Add(new ReportParameter("Pallet_label", lb_pallet_name.Text));
reportParameters.Add(new ReportParameter("Par_PalNum", LB_Number.Text));
this.rvLabel_pallet.LocalReport.SetParameters(reportParameters);
this.rvLabel_pallet.RefreshReport();
rvLabel_pallet.Visible = true;
LocalReport localReport = new LocalReport();
localReport.ReportPath = rvLabel_pallet + "//pallet_label.rdlc";
//localReport.SetParameters(reportParameters);
this.rvLabel_pallet.RefreshReport();
localReport.PrintToPrinter();
rvLabel_pallet.Visible = false;
I am using VS 2012 Ultimate, SAP Crystal Reports 13_0_13 (latest version).
The problem is that when I click on Crystal Report viewer's "next page" button, it goes on loading and never ends.
I am using the following code.
protected void btn_search_Click(object sender, EventArgs e)
{
Session["ReportDocument"] = null;
loadReport(param1,param2,param3,param4);
}
loadReport function:
private void loadReport(string Param1, string Param2, string Param3, string param4)
{
CrystalReportViewer1.Visible = true;
ReportDocument reportDocument = new ReportDocument();
string reportPath = Server.MapPath(#"~/VacantAndFilledReports/rpt_vacantposts_HR.rpt");
reportDocument.Load(reportPath);
reportDocument.SetDatabaseLogon(ID, pass, serverName, databaseName);
reportDocument.SetParameterValue("#Param1", Param1);
reportDocument.SetParameterValue("#Param2", Param2);
reportDocument.SetParameterValue("#Param3", Param3);
reportDocument.SetParameterValue("Param4", Param4);
CrystalReportViewer1.ReuseParameterValuesOnRefresh = true;
CrystalReportViewer1.AutoDataBind = true;
CrystalReportViewer1.Zoom(88);
CrystalReportViewer1.ReportSource = reportDocument;
Session["ReportDocument"] = reportDocument;
}
I have also place the code in Page_Init:
protected void Page_Init(object sender, EventArgs e)
{
if (Session["ReportDocument"] != null)
{
ReportDocument doc = (ReportDocument)Session["ReportDocument"];
CrystalReportViewer1.ReportSource = doc;
}
}
I have searched a a lot regarding Page Next button, all posts were regarding put code inside Page_Init but tried as above not work for me.
Instead of Page_init place the same piece of code at Page_Load
using Telerik.WinControls.Data;
using Telerik.WinControls.UI.Export;
namespace Directory
{
public partial class radForm : Form
{
public radForm()
{
InitializeComponent();
}
private void radForm_Load(object sender, EventArgs e)
{
// TODO: This line of code loads data into the 'directoryDataSet.DirDetails' table. You can move, or remove it, as needed.
this.dirDetailsTableAdapter.Fill(this.directoryDataSet.DirDetails);
}
// Button click
private void button1_Click(object sender, EventArgs e)
{
ExportToPDF exporter = new ExportToPDF(this.radGridView1);
//The FileExtension property allows you to change the default (*.pdf) file extension of the exported file
exporter.FileExtension = "pdf";
exporter.HiddenColumnOption = Telerik.WinControls.UI.Export.HiddenOption.DoNotExport;
// This to make the grid fits to the PDF page width
exporter.FitToPageWidth = true;
// Exporting data to PDF is done through the RunExport method of ExportToPDF object
string fileName = "c:\\Directory-information.pdf";
exporter.RunExport(fileName);
}
}
}
Some how Im missing something here and my gridview isn't exporting into pdf and no file creation takes place.
private void button1_Click(object sender, EventArgs e)
{
ExportToPDF exporter = new ExportToPDF(this.radGridView1);
exporter.FileExtension = "pdf";
exporter.HiddenColumnOption = Telerik.WinControls.UI.Export.HiddenOption.DoNotExport;
exporter.ExportVisualSettings = true;
exporter.PageTitle = "Directory Details";
exporter.FitToPageWidth = true;
string fileName = "c:\\Directory-information.pdf";
exporter.RunExport(fileName);
MessageBox.Show("Pdf file created , you can find the file c:\\Directory-informations.pdf");
}