private void Export_pdf(string branch_code,DataTable dt) { try { if (dt.Rows.Count > 0) { string file_path = tbFilePath.Text.Trim() + "\\" + branch_code.Trim() + "_" + dp_from_date.Text.Trim().Replace("/", ".") + "_" + dp_to_date.Text.Trim().Replace("/", ".") + ".pdf"; //string file_path = tbFilePath.Text.Trim() + "\\" + branch_code.Trim() + ".pdf"; //export PDF Rpt_PHT18 cry = new Rpt_PHT18(); cry.SetDataSource(dt); string title = "", Fromdate = "", Todate = ""; string title2 = ""; title = "DANH SÁCH CÁC THẺ CẦN GIA HẠN "; Fromdate = dp_from_date.Text.Trim(); Todate = dp_to_date.Text.Trim(); //title2 = "(Từ ngày " + dp_from_date.Text.Trim() + " đến ngày " + dp_to_date.Text.Trim() + " )"; cry.SetParameterValue("title", title); cry.SetParameterValue("Fromdate", Fromdate); cry.SetParameterValue("Todate", Todate); //cry.SetParameterValue("title2", title2); ExportOptions CrExportOptions; DiskFileDestinationOptions CrDiskFileDestinationOptions = new DiskFileDestinationOptions(); PdfRtfWordFormatOptions CrFormatTypeOptions = new PdfRtfWordFormatOptions(); CrDiskFileDestinationOptions.DiskFileName = file_path;// tbFilePath.Text.Trim() + "\\" + card_number.Trim() + ".pdf";//"c:\\csharp.net-informations.pdf"; CrExportOptions = cry.ExportOptions; { CrExportOptions.ExportDestinationType = ExportDestinationType.DiskFile; CrExportOptions.ExportFormatType = ExportFormatType.PortableDocFormat; CrExportOptions.DestinationOptions = CrDiskFileDestinationOptions; CrExportOptions.FormatOptions = CrFormatTypeOptions; } cry.Export(); //--Fix for Load Report failse if (cry != null) { cry.Close(); cry.Dispose(); } } } catch (Exception ex) { //MessageBox.Show("Err Export_pdf: \n Branch: "+ branch_code +"\n" + ex.ToString()); string[] row = { branch_code, ex.ToString() }; dgv_err.Rows.Add(row); } }
public virtual CrystalDecisions.CrystalReports.Engine.ReportDocument CreateReport() { Rpt_PHT18 rpt = new Rpt_PHT18(); rpt.Site = this.Site; return rpt; }