private void printToFile(string fileName) { ListReport list = new ListReport(); try { ExportOptions CrExportOptions; DiskFileDestinationOptions CrDiskFileDestinationOptions = new DiskFileDestinationOptions(); PdfRtfWordFormatOptions CrFormatTypeOptions = new PdfRtfWordFormatOptions(); CrDiskFileDestinationOptions.DiskFileName = fileName; CrExportOptions = list.ExportOptions; { CrExportOptions.ExportDestinationType = ExportDestinationType.DiskFile; CrExportOptions.ExportFormatType = ExportFormatType.PortableDocFormat; CrExportOptions.DestinationOptions = CrDiskFileDestinationOptions; CrExportOptions.FormatOptions = CrFormatTypeOptions; } //need to set the datasource or it wont work list.SetDataSource(playerInfoTable); //refresh the data list.Refresh(); DataRow theRow = playerInfoDataSet.FileDetails.Rows[0]; list.SetParameterValue("nameOfList", theRow["FileName"]); list.Export(); } catch (Exception ex) { MessageBox.Show(ex.ToString()); } }
public virtual CrystalDecisions.CrystalReports.Engine.ReportDocument CreateReport() { ListReport rpt = new ListReport(); rpt.Site = this.Site; return rpt; }
private void printList() { //fake the enter key pressed so the row changes get committed. The changes wouldnt //print if the enter key wasnt pressed on the current edited row. fakeEnterPressed(); //create the reportList ListReport list = new ListReport(); //Open the PrintDialog PrintDialog printDlg = new PrintDialog(); DialogResult dr = printDlg.ShowDialog(); if (dr == DialogResult.OK) { //Get the Copy times int nCopy = printDlg.PrinterSettings.Copies; //Get the number of Start Page int sPage = printDlg.PrinterSettings.FromPage; //Get the number of End Page int ePage = printDlg.PrinterSettings.ToPage; //Get the printer name string PrinterName = printDlg.PrinterSettings.PrinterName; try { //Set the printer name to print the report to. By default the sample //report does not have a defult printer specified. This will tell the //engine to use the specified printer to print the report. Print out //a test page (from Printer properties) to get the correct value. list.PrintOptions.PrinterName = PrinterName; //need to set the datasource or it wont work list.SetDataSource(playerInfoTable); //refresh the data list.Refresh(); //get the list name and send it as a parameter to print DataRow theRow = playerInfoDataSet.FileDetails.Rows[0]; list.SetParameterValue("nameOfList", theRow["FileName"]); //Start the printing process. Provide details of the print job //using the arguments. list.PrintToPrinter(nCopy, false, sPage, ePage); } catch (Exception err) { MessageBox.Show(err.ToString()); } } }