水晶报表配置工具 [英] Crystal Reports Configuration Tool

查看:198
本文介绍了水晶报表配置工具的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个Crystal报表,包含50个子报表,每个子报表都有多个参数。由于Crystal Reports IDE坚持要为每个子报表输入所有参数,因此将其从一个数据库切换到另一个数据库。

I have a Crystal report with 50 odd subreports, each with loads of parameters. Switching it from one database to another takes ages as the Crystal Reports IDE insists that you enter all the parameters for each sub-report.

我想知道是否可以在C#中编写一个快速工具以查看rpt文件中所有子报表的当前数据库配置,最好切换到其他数据库。

I'm wondering if it's possible to write a quick tool in C# to view the current database config of all of the sub-reports in an rpt file, and ideally to switch to a different database.

不幸的是或幸运的)我没有很多经验的Crystal对象模型 - 任何人都知道从哪里开始?

Unfortunately (or fortunately) I don't have much experience of the Crystal object model - anyone know where to start?

谢谢,
Jon。

Thanks, Jon.

推荐答案

这应该可以做到。显然,替换密码和用户名称。

This should do the job. Obviously replace the passwords and User names where neccesary.

Private Sub ProcessFile(ByVal FileName As String)
        Dim CR As Engine.ReportDocument = Nothing
        Try
            CR = New Engine.ReportDocument
            CR.Load(FileName, CrystalDecisions.Shared.OpenReportMethod.OpenReportByDefault)

            'Recurse thru Report
            RecurseAndRemap(CR)
            'Save File
            CR.SaveAs("OutPutFilePath")

        Catch ex As Exception
            MessageBox.Show(ex.Message)
        Finally
            If Not CR Is Nothing Then
                CR.Close()
                CR.Dispose()
            End If
        End Try
    End Sub

    Private Sub RecurseAndRemap(ByVal CR As Engine.ReportDocument)
        For Each DSC As CrystalDecisions.Shared.IConnectionInfo In CR.DataSourceConnections
            DSC.SetLogon("YourUserName", "YourPassword")
            DSC.SetConnection("YouServerName", "YourDatabaseName", False)
        Next

        CR.SetDatabaseLogon("YourUserName", "YourPassword")

        For Each Table As Engine.Table In CR.Database.Tables
            Table.LogOnInfo.ConnectionInfo.UserID = "YourUserName"
            Table.LogOnInfo.ConnectionInfo.Password = "YourPassword"
        Next

        If Not CR.IsSubreport Then
            For Each SR As Engine.ReportDocument In CR.Subreports
                RecurseAndRemap(SR)
            Next
        End If
    End Sub

希望能帮助Cheers Ben

Hope that helps Cheers Ben

这篇关于水晶报表配置工具的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆