Grails Web アプリケーション プロジェクトに birt-report プラグインをインストールしましたが、使い方がわかりません。私は2つのユースケースを持っています:
- BIRT Web ビューアーを生成し、GSP ページに表示 (チャート レポートを表示)
- BIRT レポートを他のファイル形式 (PDF、Word など) に生成します。
誰でもこれを行う方法の例を提供できますか?
Grails Web アプリケーション プロジェクトに birt-report プラグインをインストールしましたが、使い方がわかりません。私は2つのユースケースを持っています:
誰でもこれを行う方法の例を提供できますか?
基本的に、プラグインのドキュメント ( http://grails.org/plugin/birt-report )に記載されている例を使用できます。1. HTML レポートの生成に使用します。BIRT は GSP ではなく HTML を生成することに注意してください。GSP ページ内で出力 HTML をレンダリングできます。
// generate html output and send it to the browser
def show() {
String reportName = params.remove('id')
String reportExt = 'pdf'
params.remove('action')
params.remove('controller')
params.remove('name')
def options = birtReportService.getRenderOption(request, 'html')
def result=birtReportService.runAndRender(reportName, params, options)
response.contentType = 'text/html'
response.outputStream << result.toByteArray()
return false
}
ダウンロード用のPDFを生成
def downloadAsPDF() { String reportName = params.remove('id') String reportExt = 'pdf' params.remove('action') params.remove('controller') params.remove('name') def options = birtReportService .getRenderOption(request, 'pdf') def result=birtReportService.runAndRender(reportName, params, options) response.setHeader("Content-disposition", "attachment; filename=" +reportName + "."+reportExt); response.contentType = 'application/pdf' response.outputStream << result.toByteArray() return false }