2017-01-23 8 views
0

私のPrintReport funtionが機能しますが、に直接レポートを印刷して、ダイアログボックスを作成せずに、PowerBuilderからレポートを直接印刷したいとします。どうすればこれを達成できますか?また、同時にページ範囲を指定することはできますか?ダイアログボックスなしのレポートの印刷

私はCrystal Reports 11.5とPowerBuilder 12.5を使用しています。

答えて

0

PowerBuilderには 'PrintReport'メソッドがありません。これがアプリケーションコードまたはCrystalの中にあるかどうかは不明です。データウィンドウを印刷する場合は、[印刷仕様 - 印刷前にプロンプ​​ト]オプションをオンにします。ウィンドウ内の

+0

(例えば、ボタンの)任意のコントロールで、次の

String module String Folder, FileName Datawindow theDw OLEObject g_ole_crx_application OLEObject g_ole_crx_report OLEObject g_ole_crx_connection_info OLEObject g_ole_crx_export_options OLEObject g_ole_crx_report_controls String gs_rpt_filename, queryString, report_folder, report_file OLEObject myoleobject Long gi_return //Please remove those variables you dont need 

2 - [貼り付け]を働いていますOleObjectを使用し、CrystalRuntime.ApplicationにConnectToNewObjectを使用します。接続は成功し、レポートが表示されます。埋め込みレポートビューアに付属するデフォルトのツールバーには印刷ボタンがあります。そのツールバーボタンは正常に機能し、ダイアログボックスを開いてプリンタを選択し、選択したプリンタに印刷を送信します。私は印刷ダイアログボックスを使わずにレポートを印刷したかったのです。私はこの問題を解決しました。 133文字しか残っていないので、このページの回答セクションに詳細を投稿する必要があります。 – Berka

+0

PrintReportは、挿入可能なCrystalレポートActiveXコントロールのメソッドです。 ActiveXコントロールなしではPowerBuilderで動作しません。私は解決しようとしている別の問題があります。水晶レポートの総ページ数はどのように取得できますか? – Berka

0

の1-宣言インスタンス変数あなたは私がPowerBuilderでのCrystal Reportsの

String LoadFrom, LoadFile="C:\BT\SVN\Crystal\PB\app_reports_by_company_module.rpt" 
Integer Object_Id 

g_ole_crx_application = CREATE OLEObject 

gi_return = g_ole_crx_application.ConnectToNewObject('CrystalDesignRunTime.Application.11') 

if gi_return < 0 then 

     MessageBox("Error", "Not connected to Crystal report") 
     return 

else 

     gs_rpt_filename = LoadFile 
     g_ole_crx_report = g_ole_crx_application.OpenReport(gs_rpt_filename) 

//Returns 0 if the report file does not exist or if an error occurs. 

end if 

queryString = g_ole_crx_report.ApplicationName 
g_ole_crx_connection_info = 
g_ole_crx_report.database.tables[1].ConnectionProperties 
g_ole_crx_connection_info.deleteAll 


//g_ole_crx_report_controls = g_ole_crx_report.PageGenerator.Pages 

String ConnectInfo = "" 

//after deleting connection properties , add new connection properties 
g_ole_crx_connection_info.add("Data Source", SQLCA.ServerName) 
g_ole_crx_connection_info.add("Initial Catalog", SQLCA.Database) 
g_ole_crx_connection_info.add("Database Type", "OLE DB (ADO)") 
g_ole_crx_connection_info.add("Provider", "SQLNCLI10") 
g_ole_crx_connection_info.add("User ID", SQLCA.logid) 
g_ole_crx_connection_info.add("Password", SQLCA.logpass) 
ConnectInfo += "Provider='SQLNCLI10';Data Source='" + SQLCA.ServerName + "';" 
ConnectInfo += "Initial Catalog='" + SQLCA.Database + "';DatabaseType='OLE DB (ADO)';" 
ConnectInfo += "User ID=" + SQLCA.logid + ";Password=" + SQLCA.logpass 
g_ole_crx_connection_info.add("ConnectInfo", ConnectInfo) 

g_ole_crx_report.database.Verify 

//add parameters if there are any 

//g_ole_crx_report.ParameterFields.GetItemByName("comp_code").AddCurrentValue('C001') 

// here is the way how you can send print to the printer without print dialog box 

// first set printer 

g_ole_crx_report.SelectPrinter("HP LaserJet 2200 Series PCL 5","HP LaserJet 2200 Series PCL 5", "LPT1") 

// now use the PrintOut method 

g_ole_crx_report.PrintOut (FALSE, 1, TRUE, 1, 1) 

// if you have insertable control to view crystal report you can use ReportSource and ViewReport 

// i have it in a tab page with the name ole_view 

// make sure you also set the source 

//tab_1.tp_preview.ole_view.object.ReportSource(g_ole_crx_report) 
//tab_1.tp_preview.ole_view.object.ViewReport 



// Reference pdf : Crystal Reports XI Technical Reference Guide 

// that will work hopefully 
+0

上記のコードのPrintOut関数は、最初のページをプリンタに送信します(最後の2つのパラメータ1,1)。3つのページがあり、プリンタに送信したい場合は、関数の最後の2つのパラメータは1,3になります。構文:PrintOut([promptUser]、[numberOfCopy]、[collat​​ed]、 [startPageN]、[stopPageN]) – Berka

+0

また、ConnectToNewObject関数が( 'CrystalDesignRunTime.Application.11')に接続していることにも注意してください。 CrystalDesignRunTime PrintOutメソッドに必要です。 – Berka

+0

更新のみ:PrintOutメソッドにCrystalDesignRunTimeは必要ありません。このメソッドは、CrystalRuntime.Application.xxで動作します。 – Berka

関連する問題