MS-Help Crystal Report Knowledge Pickup

xiaoxiao2021-03-06  106

1.Web Forms Viewer report binding ReportDocument crReportDocument; crReportDocument = new tempCrystalReport (); crReportDocument.SetDataSource (ds.Tables [0]); CrystalReportViewer1.ReportSource = crReportDocument;. 2 Web Forms Viewer to view reports in Microsoft Internet An ASP.NET Web Form Control running within Information Server (IIS). The main function of the viewer is to carry and update the Crystal report page in the HTML format on the client.

This Crystal Reports control works the same as other web application controls in the Visual Studio .NET environment: the server-side controls are rendered as HTML and send the HTML to the client.

To carry the requested report page in an HTML format, the web form viewer control interacts with the reporting web services on the local Web server or the report web service on the remote server. 3. Export report

Export format

Adobe acrobat (.pdf)

Crystal Reports for Visual Studio .NET License Agreement (.rpt)

HTML 3.2 and 4.0 (.html)

Microsoft Excel (.xls)

Microsoft Rich Text (.rtf)

Microsoft Word (.doc)

Note that the ASPNET account must have permission to write the folder exported to the report. If the folder does not set at least change permissions, you will receive an error message telling you that the temporary report file is wrong. This error message is because the ASPNET account creates a temporary report file when export, but it fails due to insufficient permissions when trying to write the report file to the export folder. Manually created folders may not automatically assign full control to an ASPNET account. [C #] // Declare the variable and get the export option. ExportOptions exportOpts = new ExportOptions (); ExcelFormatOptions excelFormatOpts = new ExcelFormatOptions (); DiskFileDestinationOptions diskOpts = new DiskFileDestinationOptions (); exportOpts = Report.ExportOptions;

// Set an Excel format option. ExcelMatopts.ExceluseConstantColumnWidth = true; exportopts.exportFormattype = exportFormattype.excel; exportopts.formatoptions = excelFormatopts;

/ / Set the disk file option and export. Exportopts.exportDestinationType.DiskFile; diskopts.diskFileName = filename; exportopts.destinationOptions = diskopts;

Report.export (); export as PDF

The following example demonstrates how to export the report as a PDF format and send it to the client machine.

[Visual Basic]

'Define Crystal Reports Variables

DIM crreportDocument as reportDocument

DIM CREXPORTOPTIONS AS ExportOptions

DIM CRDISKFILEDESTINATIONOPTIONOS DISKFILEDESTINATIONOPTIONSDIM FNAME AS STRING

'The following code can be placed directly in the form of the form.

After the call of 'InitializationComponent (), or put it,

The 'Button_Click event inside, in this event, the client uses this button

'Take the printable copy of the report.

crreportDocument = new reportDocument ()

'The following code line load

'Sample report "chart.rpt"

CrreportDocument.Load ("C: / Program Files / Microsoft Visual Studio .NET 2003 / Crystal Reports / Samples / Reports / Feature Examples / Chart.rpt")

FNAME = "c: / exports /" & session.SessionId.toString & ".pdf"

CRDiskFileDestinationOptions = New DiskFileDestinationOptions ()

CRDiskFileDestinationOptions.diskFileName = FNAME

CrexportOptions = crreportDocument.exportOptions

With CrexportOptions

.DestinationOptions = CRDiskFileDestinationOptions

.ExportDestinationType = exportDestinationType.diskfile

. EXPORTFORMATTYPE = ExportFormattype.portablesDocFormat

End with

crreportDocument.export ()

'The following code writes the PDF file

'Client browser.

Response.clearContent ()

Response.clearheaders ()

Response.contentType = "Application / PDF"

Response.writefile (FNAME)

Response.flush ()

Response.close ()

'Delete the exported file from disk

System.IO.File.delete (FNAME)

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

New Post(0)