经典asp的水晶报告库

时间:2010-08-13 14:49:04

标签: crystal-reports asp-classic

是否有适用于经典asp的库。我想在经典的asp中从rpt文件创建一个pdf文件。我不想安装水晶报告。有办法吗?

-Vivek

1 个答案:

答案 0 :(得分:2)

您只能使用Crystal Reports可再发行的DLL打开报告文件并使用它生成PDF。

我从未尝试直接从ASP打开Crystal Reports库,但应该没问题(或者你可以在VB6中创建一个COM Dll,如果可以的话)

我在使用Crystal Reports 9的VB6 DLL中的一些代码:

Private Sub Export(ReportFile as string)
    Dim crxReport As Report
    Set crxReport = Prepare(ReportFile )

    crxReport.ExportOptions.FormatType = crEFTPortableDocFormat
    crxReport.ExportOptions.DestinationType = crEDTDiskFile
    crxReport.ExportOptions.DiskFileName = "C:\export\export.pdf"
    crxReport.Export (False)
end sub


Private Function Prepare(ReportFile as string) As Report

    Dim CRapp As CRAXDRT.Application
    Set CRapp = New CRAXDRT.Application
    Dim crxReport As Report
    Dim aDatabaseObject As Database

    Dim aDatabaseTableObject As CRAXDRT.DatabaseTable
    Dim objConn As ConnectionProperty


    Set CRapp = New CRAXDRT.Application
    CRapp.SetLicenseKeycode ("XXXXXXXXXXXXXXXXXXXXXXXX")
    Set crxReport = CRapp.OpenReport(ReportFile)

    Set aDatabaseObject = crxReport.Database
    Set cnn = New ADODB.Connection
    cnn.ConnectionString = MyConnectionString()

    Set aDatabaseObject = crxReport.Database

    For Each aDatabaseTableObject In aDatabaseObject.Tables
        Dim objCPProperties As CRAXDRT.ConnectionProperties
        aDatabaseTableObject.DllName = "crdb_ado.dll"
        Set objCPProperties = aDatabaseTableObject.ConnectionProperties
        objCPProperties.DeleteAll
        objCPProperties.Add "Provider", "SQLOLEDB"
        objCPProperties.Add "Data Source", cnn.Properties.Item("Data Source").Value
        objCPProperties.Add "Initial Catalog", cnn.Properties.Item("Initial Catalog").Value
        objCPProperties.Add "User ID", cnn.Properties.Item("User ID").Value
        objCPProperties.Add "Password", cnn.Properties.Item("Password").Value
        aDatabaseTableObject.Location = aDatabaseTableObject.Name
    Next

    Set Prepare = crxReport

End Function