如何导出Crystal报表?!

Meditate 2002-06-26 12:01:49
基于Web的应用程序怎样将报表导出到服务器上的特定目录中?
或者用其他方法将此报表以xls格式传递给最终用户?

请高人赐教!!!
...全文
152 8 打赏 收藏 转发到动态 举报
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
tianlon 2002-08-03
  • 打赏
  • 举报
回复
收藏!
Meditate 2002-07-01
  • 打赏
  • 举报
回复
yunmiaojing你说得没错!但是那实在winForm中,实现这些功能很简单!可是在Web 中就不一样了!
还请高人指点呀!
dason2u 2002-06-30
  • 打赏
  • 举报
回复
同意楼上。不过那是在WinForm中。
yumiaojing 2002-06-28
  • 打赏
  • 举报
回复
预览报表后,报表最上端不是有个按钮可以实现你所需的功能吗,而且还可以转换成其它格式呢
Meditate 2002-06-28
  • 打赏
  • 举报
回复
楼上的仁兄,我按照文档中的代码作了,可是当我执行crReportDocument.Export时报错,说有另一个程序正在使用此报表,如何解决?
mmkk 2002-06-26
  • 打赏
  • 举报
回复
借问一下:你的图形分析文件可以显示吗?
mmkk 2002-06-26
  • 打赏
  • 举报
回复
请问一下,为什么我的crystal report图形分析文件没有办法显示?
lixigang 2002-06-26
  • 打赏
  • 举报
回复
给你一个vb的函数看看:

Function ExportReport(ByVal crReportDocument As ReportDocument, ByVal PhysicalApplicationPath As String, ByVal FileName As String, ByVal format As String) As String
' This subroutine uses a case statement to determine the selected export format from the dropdownlist
' menu and then sets the appropriate export options for the selected export format. The report is
' exported to a subdirectory called "Exported".

'Check to see if the application directory has a subdirectory called "Exported".
'If not, create the directory since exported files will be placed here.
'This uses the Directory class of the System.IO namespace.

'PhysicalApplicationPath = request.PhysicalApplicationPath

Dim ExportPath As String
ExportPath = PhysicalApplicationPath + "Exported\"
If Directory.Exists(ExportPath) = False Then
Directory.CreateDirectory(PhysicalApplicationPath + "Exported\")
End If

Dim crExportOptions As ExportOptions
Dim crDiskFileDestinationOptions As DiskFileDestinationOptions

' First we must create a new instance of the diskfiledestinationoptions class and
' set variable called crExportOptions to the exportoptions class of the reportdocument.
crDiskFileDestinationOptions = New DiskFileDestinationOptions()
crExportOptions = crReportDocument.ExportOptions


'Find the export type specified in the dropdownlist and export the report. The possible export format
'types are Rich Text(RTF), Portable Document (PDF), MS Word (DOC), MS Excel (XLS), Crystal Report (RPT),
'HTML 3.2 (HTML) and HTML 4.0 (HTML)
'
'Though not used in this sample application, there are options that can be specified for various format types.
'When exporting to Rich Text, Word, or PDF, you can use the PdfRtfWordFormatOptions class to specify the
'first page, last page or page range to be exported.
'When exporting to Excel, you can use the ExcelFormatOptions class to specify export properties such as
'the column width etc.

Select Case format 'this contains the value of the selected export format.

Case "RTF" '"Rich Text (RTF)"
'--------------------------------------------------------------------
'Export to RTF.

'append a filename to the export path and set this file as the filename property for
'the DestinationOptions class
crDiskFileDestinationOptions.DiskFileName = ExportPath + FileName + ".rtf"

'set the required report ExportOptions properties
With crReportDocument.ExportOptions
.ExportDestinationType = ExportDestinationType.DiskFile
.ExportFormatType = ExportFormatType.RichText
.DestinationOptions = crDiskFileDestinationOptions
End With
'--------------------------------------------------------------------
Case "PDF" '"Portable Document (PDF)"
'Export to PDF

'append a filename to the export path and set this file as the filename property for
'the DestinationOptions class
crDiskFileDestinationOptions.DiskFileName = ExportPath + FileName + ".pdf"

'set the required report ExportOptions properties
With crExportOptions
.DestinationOptions = crDiskFileDestinationOptions
.ExportDestinationType = ExportDestinationType.DiskFile
.ExportFormatType = ExportFormatType.PortableDocFormat
End With
'--------------------------------------------------------------------
Case "DOC" '"MS Word (DOC)"
'Export to Word

'append a filename to the export path and set this file as the filename property for
'the DestinationOptions class
crDiskFileDestinationOptions.DiskFileName = ExportPath + FileName + ".doc"

'set the required report ExportOptions properties
With crReportDocument.ExportOptions
.ExportDestinationType = ExportDestinationType.DiskFile
.ExportFormatType = ExportFormatType.WordForWindows
.DestinationOptions = crDiskFileDestinationOptions
End With
'--------------------------------------------------------------------
Case "XLS" '"MS Excel (XLS)"
'Export to Excel

'append a filename to the export path and set this file as the filename property for
'the DestinationOptions class
crDiskFileDestinationOptions.DiskFileName = ExportPath + FileName + ".xls"

'set the required report ExportOptions properties
With crReportDocument.ExportOptions
.ExportDestinationType = ExportDestinationType.DiskFile
.ExportFormatType = ExportFormatType.Excel
.DestinationOptions = crDiskFileDestinationOptions
End With
'--------------------------------------------------------------------
Case "RPT" '"Crystal Report (RPT)"
'Export to Crystal reports:

'append a filename to the export path and set this file as the filename property for
'the DestinationOptions class
crDiskFileDestinationOptions.DiskFileName = ExportPath + FileName + ".rpt"

'set the required report ExportOptions properties
With crReportDocument.ExportOptions
.ExportDestinationType = ExportDestinationType.DiskFile
.ExportFormatType = ExportFormatType.CrystalReport
.DestinationOptions = crDiskFileDestinationOptions
End With
End Select 'export format

'Once the export options have been set for the report, the report can be exported. The Export command
'does not take any arguments
' Try
' Export the report
crReportDocument.Export()
ExportReport = ""
' Catch Err As Exception
' ExportReport = Err.Message.ToString
' End Try

End Function
Crystal Reports for Visual Studio 2005 SDK Tutorials: Sample Code Projects 1. This setup contains sample code projects for Crystal Reports for Visual Studio 2005. 2. This sample code corresponds exactly to the tutorials contained in the Crystal Reports for Visual Studio 2005 online help. Each project has been built by following the instructions in their corresponding tutorials, and instructions and explanations have been placed within the tutorial sections rather than in code comments. Therefore, it is highly recommended that you consult the tutorials for a full explanation of the structure and best practices demonstrated within this code. 3. If you wish to run the tutorial sample code projects, check the code for any machine-specific values and confirm that they are customized for your specific machine. These may include: * ODBC data source settings for reports * file directory paths * network printer paths * API property settings for database connections, including: * database server names * database names * userIDs * passwords * complete database connection strings 4. For security reasons it is recommended that you use Integrated Security (Windows Authentication) for your SQL Server database connectivity. If you plan to use SQL Authentication, it is strongly recommended that you create a database account with limited access to your database. (Both versions of authentication are demonstrated in the tutorials.) For more information on security, including how to create a limited access database account, see the SDK Fundamentals section of the Crystal Reports for Visual Studio 2005 documentation. Asp.net2.0水晶报表(CrystalReports)事例源码大全(C#) 这些例子实现了水晶报表的查看、柱状图显示、打印、导出、缩放等基本功能,如果想了解更多比如说利用DataSet方式、Push、Pull等模式需要自己更深一步的研究了 难得的Asp.net2.0水晶报表源码,请珍藏!

110,571

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧