我需要以PDF
格式将水晶报表导出到本地系统。
我已经使用过ExporttoDesk
,但它保存在服务器中。我需要将其提供给用户。
可能吗 ?
我用过ExporttoStream
。但它也不适合我。
请告诉我实现这一目标的方法。
谢谢,拉克什。
我需要以PDF
格式将水晶报表导出到本地系统。
我已经使用过ExporttoDesk
,但它保存在服务器中。我需要将其提供给用户。
可能吗 ?
我用过ExporttoStream
。但它也不适合我。
请告诉我实现这一目标的方法。
谢谢,拉克什。
Try this on Button's click
try
{
ExportOptions CrExportOptions ;
DiskFileDestinationOptions CrDiskFileDestinationOptions = new DiskFileDestinationOptions();
PdfRtfWordFormatOptions CrFormatTypeOptions = new PdfRtfWordFormatOptions();
CrDiskFileDestinationOptions.DiskFileName = "c:\\csharp.net-informations.pdf";
CrExportOptions = cryRpt.ExportOptions;
{
CrExportOptions.ExportDestinationType = ExportDestinationType.DiskFile;
CrExportOptions.ExportFormatType = ExportFormatType.PortableDocFormat;
CrExportOptions.DestinationOptions = CrDiskFileDestinationOptions;
CrExportOptions.FormatOptions = CrFormatTypeOptions;
}
cryRpt.Export();
}
catch (Exception ex)
{
MessageBox.Show(ex.ToString());
}
Read its explanation here
当我们有参数时怎么做?
Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs)
Dim Report As ReportDocument = New ReportDocument()
Report.Load(Server.MapPath("~/CrystalReport.rpt"))
Report.SetDatabaseLogon("sa", "######", "IT250WS", "demo")
CrystalReportViewer1.ReportSource = Report
End Sub
Protected Sub btnPDF_Click(ByVal sender As Object, ByVal e As EventArgs)
Dim Report As ReportDocument = New ReportDocument()
Report.Load(Server.MapPath("~/CrystalReport.rpt"))
Report.SetParameterValue("@EmpId", 1)
Report.SetDatabaseLogon("sa", "######", "IT250WS", "demo")
Response.Buffer = False
Response.ClearContent()
Response.ClearHeaders()
Report.ExportToHttpResponse(ExportFormatType.PortableDocFormat, Response, True, "File_Name")
Response.[End]()
End Sub
答案为时已晚,但它可能对像我这样的其他人有用。
using CrystalDecisions.CrystalReports.Engine;
using CrystalDecisions.Shared;
protected void Page_Load(object sender, EventArgs e)
{
ReportDocument pdfReport = new ReportDocument();
pdfReport.Load(Server.MapPath("ExportToPdf.rpt"));
pdfReport.SetDatabaseLogon("amitjain","password", @"AMITJAIN\SQL", "Northwind");
CrystalReportViewer1.ReportSource = pdfReport;
}
protected void btnExport_Click(object sender, EventArgs e)
{
ReportDocument pdfReport = new ReportDocument();
pdfReport.Load(Server.MapPath("ExportToPdf.rpt"));
pdfReport.SetDatabaseLogon("user", "password", @"AMITJAIN\SQL", "Northwind");
Response.Buffer = false;
Response.ClearContent();
Response.ClearHeaders();
pdfReport.ExportToHttpResponse(ExportFormatType.PortableDocFormat, Response, true, "Employees");
Response.End();
}
http://csharpdotnetfreak.blogspot.com/2012/01/export-crystalreports-to-pdf-word-excel.html
测试和工作。