私のPrintReport
funtionが機能しますが、に直接レポートを印刷して、ダイアログボックスを作成せずに、PowerBuilderからレポートを直接印刷したいとします。どうすればこれを達成できますか?また、同時にページ範囲を指定することはできますか?ダイアログボックスなしのレポートの印刷
私はCrystal Reports 11.5とPowerBuilder 12.5を使用しています。
私のPrintReport
funtionが機能しますが、に直接レポートを印刷して、ダイアログボックスを作成せずに、PowerBuilderからレポートを直接印刷したいとします。どうすればこれを達成できますか?また、同時にページ範囲を指定することはできますか?ダイアログボックスなしのレポートの印刷
私はCrystal Reports 11.5とPowerBuilder 12.5を使用しています。
PowerBuilderには 'PrintReport'メソッドがありません。これがアプリケーションコードまたはCrystalの中にあるかどうかは不明です。データウィンドウを印刷する場合は、[印刷仕様 - 印刷前にプロンプト]オプションをオンにします。ウィンドウ内の
の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
上記のコードのPrintOut関数は、最初のページをプリンタに送信します(最後の2つのパラメータ1,1)。3つのページがあり、プリンタに送信したい場合は、関数の最後の2つのパラメータは1,3になります。構文:PrintOut([promptUser]、[numberOfCopy]、[collated]、 [startPageN]、[stopPageN]) – Berka
また、ConnectToNewObject関数が( 'CrystalDesignRunTime.Application.11')に接続していることにも注意してください。 CrystalDesignRunTime PrintOutメソッドに必要です。 – Berka
更新のみ:PrintOutメソッドにCrystalDesignRunTimeは必要ありません。このメソッドは、CrystalRuntime.Application.xxで動作します。 – Berka
(例えば、ボタンの)任意のコントロールで、次の
2 - [貼り付け]を働いていますOleObjectを使用し、CrystalRuntime.ApplicationにConnectToNewObjectを使用します。接続は成功し、レポートが表示されます。埋め込みレポートビューアに付属するデフォルトのツールバーには印刷ボタンがあります。そのツールバーボタンは正常に機能し、ダイアログボックスを開いてプリンタを選択し、選択したプリンタに印刷を送信します。私は印刷ダイアログボックスを使わずにレポートを印刷したかったのです。私はこの問題を解決しました。 133文字しか残っていないので、このページの回答セクションに詳細を投稿する必要があります。 – Berka
PrintReportは、挿入可能なCrystalレポートActiveXコントロールのメソッドです。 ActiveXコントロールなしではPowerBuilderで動作しません。私は解決しようとしている別の問題があります。水晶レポートの総ページ数はどのように取得できますか? – Berka