0

Crystal Report を PDF にエクスポートしようとしています。コードは次のとおりです(明らかに、無実の人を保護するためにパスワードとサーバー名などが変更されています)...

public void RunReport(string outputFile, int cc, int yr, int wk)
{     
    ReportDocument rd = new ReportDocument();     
    rd.Load(FullFilePath("myreport.rpt"));     
    rd.Refresh();     
    rd.SetDatabaseLogon("userid", "password");     
    foreach (Table tbl in rd.Database.Tables)    
    {          
        tbl.LogOnInfo.ConnectionInfo.ServerName = "dbname";          
        tbl.LogOnInfo.ConnectionInfo.DatabaseName = "";          
        tbl.LogOnInfo.ConnectionInfo.UserID = "userid";          
        tbl.LogOnInfo.ConnectionInfo.Password = "password";     
    }     
    foreach (IConnectionInfo ci in rd.DataSourceConnections)     
    {          
        ci.SetLogon("userid", "password");     
    }     
    DiskFileDestinationOptions diskFileDestinationOptions = new DiskFileDestinationOptions();     
    ExportOptions exportOptions;     
    PdfRtfWordFormatOptions pdfFormatOptions = new PdfRtfWordFormatOptions();     
    diskFileDestinationOptions.DiskFileName = outputFile;     
    crExportOptions = rd.ExportOptions;     
    {          
        crExportOptions.ExportDestinationType = ExportDestinationType.DiskFile;          
        crExportOptions.ExportFormatType = ExportFormatType.PortableDocFormat;          
        crExportOptions.DestinationOptions = diskFileDestinationOptions;          
        crExportOptions.FormatOptions = pdfFormatOptions;     
    }     

    SetCurrentValuesForParameterField(rd, "IP_COMP_CODE", cc);     
    SetCurrentValuesForParameterField(rd, "IP_YEAR", yr);     
    SetCurrentValuesForParameterField(rd, "IP_WEEK", wk);          

    rd.Export();
}

private void SetCurrentValuesForParameterField(ReportDocument reportDocument, string paramFieldName, int value)
{ 
    ParameterDiscreteValue parameterDiscreteValue = new ParameterDiscreteValue(); 
    parameterDiscreteValue.Value = value.ToString();
    ParameterValues currentParameterValues = new ParameterValues(); 
    currentParameterValues.Add(parameterDiscreteValue);
    reportDocument.DataDefinition.ParameterFields[paramFieldName].ApplyCurrentValues(currentParameterValues);
}

ここで奇妙なのは、このコードを最初に書いたとき (そしてそれは SVN にあった)、最初にエクスポートを行ったときにメモリ不足であるという COM 例外が発生することです (これは ASP.NET MVC アプリにありました)。 )、しかし、その後のすべてのエクスポート(Webアプリを再起動するまで)は問題なく機能します.

生成されたエラーは次のとおりです。

First-chance exception at 0x75a2c41f in w3wp.exe: Microsoft C++ exception: _com_error at memory location 0x20dee4b0.

A first chance exception of type 'System.Runtime.InteropServices.COMException' occurred in CrystalDecisions.CrystalReports.Engine.dll

An exception of type 'System.Runtime.InteropServices.COMException' occurred in CrystalDecisions.CrystalReports.Engine.dll but was not handled in user code

Additional information: Memory full.

Failed to export the report.    

SAP の Web サイトに投稿したところ、サポート担当者がいくつかのコード変更を提案しましたが、それを含めたところ、次のエラーで完全に機能しなくなりました。

An exception of type 'CrystalDecisions.CrystalReports.Engine.DataSourceException' occurred in CrystalDecisions.ReportAppServer.DataSetConversion.dll but was not handled in user code

Additional information: Failed to load database information.
Error in File myreport {6DC42165-A38A-4CB2-85FD-A77389827FA9}.rpt:

Failed to load database information.    

コードの変更を元に戻したとき、このエラーが発生し続けました (それ以来)。レポートをまったくエクスポートできなくなりました。

彼が提案した変更により、次のコードが生成されました。

ReportDocument rd = new ReportDocument();     
rd.Load(FullFilePath("myreport.rpt"));     
ConnectionInfo connectInfo = new ConnectionInfo()     
{          
    ServerName = "dbname",          
    DatabaseName = "",          
    UserID = "userid",          
    Password = "password"     
};     
rd.SetDatabaseLogon("userid", "password");     

foreach (Table tbl in rd.Database.Tables)     
{          
    tbl.LogOnInfo.ConnectionInfo = connectInfo;          
    tbl.ApplyLogOnInfo(tbl.LogOnInfo);     
}   

現在、SAP は、私が VS.NET 2012 を使用しているため、VS.NET 統合 (単に SDK のみ) を使用していないにもかかわらず、私をサポートしないと言っています。彼らは見事に役に立たなかった。

Windows 7 64 ビットで実行しています。私がインストールした Crystal Reports SDK は、CRforVS_redist_install_64bit_13_0_4.zip で、Web サイトから入手できます。

バックエンドのデータベースは Oracle で、クライアントは 11g です。

Oracle クライアントと Crystal Reports の両方をアンインストールして再インストールしましたが、うまくいきません。レポートをエクスポートできなくなりました。

4

1 に答える 1

4

結局、すべてを 32 ビットで行う必要がありました。私は 64 ビットの Crystal を動作させることができませんでした。ひどい (失礼な) テクニカル サポートのため、SSRS 用の Crystal を破棄します。

于 2013-01-03T15:20:01.173 に答える