Muh*_*gha 7 asp.net crystal-reports visual-studio crystal-reports-2008
我想在Crystal Report的ASP.Net上做一个报告.我想,当用户点击打印时,它应该只显示一个浏览器对话框,保存,打开,另存为,应该保存PDF,或者应该出现Crystal Report打印预览,我不想先在Viewer中显示报表然后点击按钮来获得打印件或PDF,我想简单地从点击ASP按钮,我有所有的参数的想法,并知道如何使报告,我的问题就是不显示观众和采取的形式从ASP按钮报告打印PDF或打印预览对话框.我使用.Net的导出方法用于Crystal Report,但它不起作用.
您可以使用 Crystal Report 和一段代码生成 PDF....
第一:根据您的要求生成水晶报告。
第二:使用以下代码生成PDF:
将以下命名空间放在代码页的顶部
Imports CrystalDecisions.CrystalReports.Engine
Imports CrystalDecisions.Shared
Run Code Online (Sandbox Code Playgroud)变量声明
Dim CrReport As New CrystalReport1() // Report Name
Dim CrExportOptions As ExportOptions
Dim CrDiskFileDestinationOptions As New DiskFileDestinationOptions()
Dim CrFormatTypeOptions as New PdfRtfWordFormatOptions()
Run Code Online (Sandbox Code Playgroud)设置目标路径和文件名
CrDiskFileDestinationOptions.DiskFileName = "c:\RichText.pdf"
Run Code Online (Sandbox Code Playgroud)指定页面范围(可选)
crFormatTypeOptions.FirstPageNumber = 1 // Start Page in the Report
crFormatTypeOptions.LastPageNumber = 3 // End Page in the Report
crFormatTypeOptions.UsePageRange = True
Run Code Online (Sandbox Code Playgroud)设置导出选项
CrExportOptions = crReport.ExportOptions
With CrExportOptions
// Set the destination to a disk file
.ExportDestinationType = ExportDestinationType.DiskFile
// Set the format to PDF
.ExportFormatType = ExportFormatType.PortableDocFormat
// Set the destination options to DiskFileDestinationOptions object
.DestinationOptions = CrDiskFileDestinationOptions
.FormatOptions = crFormatTypeOptions
End With
Run Code Online (Sandbox Code Playgroud)捕获导出时发生的任何错误
Try
// Export the report
CrReport.Export()
Catch err As Exception
MessageBox.Show(err.ToString())
End Try
Run Code Online (Sandbox Code Playgroud)就是这样.... 现在您已准备好创建报告的 PDF。
这是您正在寻找的解决方案:
http://www.c-sharpcorner.com/UploadFile/mahesh/ExportCRtoPDF10062006161918PM/ExportCRtoPDF.aspx
以下是该网站的引用:
以下步骤将指导您实现相同的目标:
将水晶报表 (.cr) 文件添加到 ASP.NET 应用程序。在页面级别添加报表实例。
昏暗报告 As MyReport = New MyReport
在 Page_Init 上填充报告数据
Dim ds As DataSet = GetData()
报告.SetDataSource(ds)
出口报告
report.ExportToHttpResponse(ExportFormatType.PortableDocFormat, Response, False, "ExportedReport")
如果您希望将报告格式设置为其他格式,只需将 ExportFormatType 枚举值更改为 > 您所需的格式即可。
如果您想下载报告,只需将步骤 4 中 >ExportToHttpResponse 方法的第三个参数更改为 True。
| 归档时间: |
|
| 查看次数: |
34372 次 |
| 最近记录: |