private void btnPrintAllProducts_Click(object sender, EventArgs e) { RPT.rpt_All_products myRepot = new RPT.rpt_All_products(); RPT.FRM_RPT_PRODUCT myForm = new RPT.FRM_RPT_PRODUCT(); myForm.crystalReportViewerSingle.ReportSource = myRepot; myForm.ShowDialog(); }
private void btnExportExcel_Click(object sender, EventArgs e) { RPT.rpt_All_products myReport = new RPT.rpt_All_products(); ExportOptions export = new ExportOptions(); DiskFileDestinationOptions defile = new DiskFileDestinationOptions(); ExcelFormatOptions excelformat = new ExcelFormatOptions(); defile.DiskFileName = @"D:\MYReport.xls"; export = myReport.ExportOptions; export.ExportDestinationType = ExportDestinationType.DiskFile; export.ExportFormatType = ExportFormatType.Excel; export.ExportFormatOptions = excelformat; export.ExportDestinationOptions = defile; myReport.Export(); MessageBox.Show("Report Exported Successfully", "Export", MessageBoxButtons.OK, MessageBoxIcon.Information); }