2011-11-10 6 views
0

複数の.rptファイル(Crystalレポート)を1つのアプリケーションで使用する方法を知っている人はいますか?レポートを生成して.pdfに直接保存する必要がありますが、どうやってそれを行うのかはわかりません。私は単一の.rptファイルを使用していますが、複数の.rptファイルでレポートを生成する方法がわかりません。誰かが私を助けてくれる?複数の.rptファイル(クリスタルレポート)を1つのアプリケーションでどのように使用できますか?

私のコーディング:

ReportDocument cryRpt = new ReportDocument(); 
TableLogOnInfos crtableLogoninfos = new TableLogOnInfos(); 
TableLogOnInfo crtableLogoninfo = new TableLogOnInfo(); 
ConnectionInfo crConnectionInfo = new ConnectionInfo(); 
Tables CrTables; 

cryRpt.Load("C:\\rptBilling.rpt"); 

crConnectionInfo.ServerName = "ServerName"; 
crConnectionInfo.DatabaseName = "DatabaseName"; 
crConnectionInfo.UserID = "userID"; 
crConnectionInfo.Password = "Password"; 

CrTables = cryRpt.Database.Tables; 
foreach (CrystalDecisions.CrystalReports.Engine.Table CrTable in CrTables) 
{ 
    crtableLogoninfo = CrTable.LogOnInfo; 
    crtableLogoninfo.ConnectionInfo = crConnectionInfo; 
    CrTable.ApplyLogOnInfo(crtableLogoninfo); 
} 

cryRpt.SetParameterValue("@CollectionStartDate", "2011/09/14"); 
cryRpt.SetParameterValue("@CollectionEndDate", "2011/09/29"); 
cryRpt.SetParameterValue("@SpokeCode", "14");//country code 
cryRpt.SetParameterValue("@UseCollectionDate", "1");//value can be set 0 or 1 
cryRpt.SetParameterValue("@UseUploadDate", "0");//value can be set 0 or 1 
cryRpt.SetParameterValue("@UploadStartDate", "2011/09/23"); 
cryRpt.SetParameterValue("@UploadEndDate", "2011/09/23"); 

cryRpt.ExportToDisk(ExportFormatType.PortableDocFormat, "e:\\1.pdf"); 

答えて

0

あなたは別々のPDFファイルを意味している場合、あなただけのcryRpt.Load()を使用して新しいRPTをリロードできます。新しいパラメータにパラメータとSetParameterValueをクリアすることを確認してください。

編集:十分なポイントがないのにCrystal Reporting機能を使用したことがないのでコメントできませんが、同じ変数を維持できると仮定しています。 pdfでは、Load()をもう一度呼び出すことでcryRptを再利用し、すでに行ったのと同じ手順を実行しますが、必要に応じて新しい変数を使用することができます。それが複数のcryRptsを許可しない場合は、新しいものを破棄して初期化することができます。私はあなたが2つの別々のpdfファイルが必要であると仮定しているので、あなたが探しているものを誤解する可能性があります。

+0

私は、それぞれのrptファイル用に別の関数を作成する必要があるのですか?例:public static void BillingReport()、public static void AgingReport() – srahifah

関連する問題