本文介绍了在没有Crystal Reports查看器的情况下如何加载Crystal Reports?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在没有Crystal Report查看器的情况下加载Crystal报表?

How do i load crystal reports without crystal reports viewer?

推荐答案

using CrystalDecisions.CrystalReports.Engine;



protected void btn_Click( object sender, EventArgs e )
{
	try
	{
		// Get the report document
		ReportDocument report = new ReportDocument();

		// it was guessed that the .rpt file is under 'Reporting' folder of the project
		report.Load( Server.MapPath( "~/Reporting/report1.rpt" ) );

		// Stop buffering the response
		Response.Buffer = false;
		// Clear the response content and headers
		Response.ClearContent();
		Response.ClearHeaders();

		// Export the Report to Response stream in PDF format
		report.ExportToHttpResponse( ExportFormatType.PortableDocFormat, Response, false, "My Report");
	}
	catch( Exception ex )
	{
		// use any logic to show the error, e.g. label, messageBox..
	}
}



可用的格式导出

可以按以下不同格式导出报告:

ExportFormatType.PortableDocFormat 便携式文档格式(PDF)
ExportFormatType.Excel 完整报告到Excel
ExportFormatType.ExcelRecord 仅报告数据到Excel
ExportFormatType.HTML40 HTML
ExportFormatType.RichText 富文本格式(RTF)
ExportFormatType.WordForWindows MS Word



Available formats to export

The report can be exported in different formats as follow:

ExportFormatType.PortableDocFormat Portable Document Format (PDF)
ExportFormatType.Excel Complete Report to Excel
ExportFormatType.ExcelRecord Only Report Data to Excel
ExportFormatType.HTML40 HTML
ExportFormatType.RichText Rich Text Format (RTF)
ExportFormatType.WordForWindows MS Word




这篇关于在没有Crystal Reports查看器的情况下如何加载Crystal Reports?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-14 06:33