Dynamic crystal report

xiaoxiao2021-03-06  106

An instance of the official VB.NET program for the creation of a dynamic crystal report. Exehttp://blog.9cbs.net/haibodotNet/archive/2003/12/21546.aspx

Create a report that is not subject to database http://blog.9cbs.net/babyt/category/39074.aspx

You can also create some empty formula fields, pre-defense on the report, and then dynamically support the formula field. CrreportDocument.SetDataSource (DS); ExportOptions CrexportOptions; // Export Option DiskFileDestinationOptions CRDiskFileDestinationOptions; String FName; // Export full name

// String FileName = ""; String FileName = "my.pdf"; String _SystemPath = Request.PhysicalApplicationPath; (! System.IO.Directory.Exists (_SystemPath)) if System.IO.Directory.CreateDirectory (_SystemPath); Fname = _SystemPath filename; // Export full name

CRDiskFileDestinationOptions = new diskfileDestinationOptions (); CRDiskFileDestinationOptions.diskFileName = FNAME DISKFILENAME = FNAME

crExportOptions = crReportDocument.ExportOptions; crExportOptions.DestinationOptions = crDiskFileDestinationOptions; crExportOptions.ExportDestinationType = ExportDestinationType.DiskFile; crExportOptions.ExportFormatType = ExportFormatType.PortableDocFormat; crReportDocument.Export ();

/ / / =============================================== =========================================================== // Print and export crystal reports / / ================================================================================================================================================================================================== ================================================ ///

/// print one Crystal report /// /// Report Path /// DataSet Public void Printreport (string reportPath, string PrinterPath, string passWrd) {ReportDocument crystalReportObject = new ReportDocument (); // crystalReportObject crystalReportObject.Load (reportPath); // "e: //temp//crt.rpt". // crystalReportObject.s / /crystalReportObject.SetDataSource(reportSet); crystalReportObject.Refresh (); this.SetConnectionInfo (crystalReportObject, passWrd); //crystalReportObject.PrintOptions.PrinterName = @ "// office1 / HP1000"; crystalReportObject.PrintOptions.PrinterName = PrinterPath; try { CrystalReportObject.printToprinter (1, False, 0, 0);

} Catch {;} finally {crystalReportObject.Close ();} // CrystalDecisions.Web.CrystalReportViewer myView = new CrystalDecisions.Web.CrystalReportViewer (); // myView.LogOnInfo} public void printReport (string PrinterPath, ReportDocument crystalReportObject) {

crystalReportObject.PrintOptions.PrinterName = PrinterPath; try {crystalReportObject.PrintToPrinter (1, false, 0, 0);} catch {;} finally {crystalReportObject.Close ();} // CrystalDecisions.Web.CrystalReportViewer myView = new CrystalDecisions.Web .CrystalReportViewer (); // myview.logoninfo}

// public ReportDocument InitReportDoc (DataSet myDs, string reportPath, string passWrd) // {// ReportDocument oRD = new ReportDocument (); // oRD.Load (reportPath); // oRD.SetDataSource (myDs); // oRD. Refresh (); // this.setConnectionInfo (ORD, Passwrd); // Return ORD; ////}

public void ExportCrystalReport (string targetFileName, string reportPath, string docFormat, string passWrd) {ReportDocument oRD = new ReportDocument (); ExportOptions oExO; DiskFileDestinationOptions oExDo = new DiskFileDestinationOptions (); oRD.Load (reportPath); //oRD.SetDataSource(myDS ); Ord.refresh (); this.SetConnectionInfo (ORD, Passwrd);

oExDo.DiskFileName = targetFileName; oExO = oRD.ExportOptions; oExO.ExportDestinationType = ExportDestinationType.DiskFile; switch (docFormat) {case "pdf": oExO.ExportFormatType = ExportFormatType.PortableDocFormat; break; case "doc": oExO.ExportFormatType = ExportFormatType .WordForWindows; break; case "xls": oExO.ExportFormatType = ExportFormatType.Excel; break; case "htm": oExO.ExportFormatType = ExportFormatType.HTML40; break; case "html": oExO.ExportFormatType = ExportFormatType.HTML40; break; default: oExO.ExportFormatType = ExportFormatType.Excel; break;} oExO.DestinationOptions = oExDo; oRD.Export (); oRD.Close ();} public void ExportCrystalReport (ReportDocument oRD, string docFormat, string targetFileName) {// ReportDocument oRD = New reportDocument (); ExportOptions OEXO; DiskFileDestinationOptions OEXDO = New DiskFileDestinationOptions (); // ORD.LOAD (ReportPath); // ORD.SetDataSource (Myd S); //ord.refresh (); //this.setConnectionInfo (monograd, quaswrd);

转载请注明原文地址:https://www.9cbs.com/read-100138.html

New Post(0)