Mew*_*ewZ 5 grails birt grails-plugin
我在Grails Web应用程序项目上安装了birt-report插件,但我无法理解使用它.我有2个用例:
有谁能提供如何做到这一点的例子?
基本上,您可以使用插件文档中提到的示例(http://grails.org/plugin/birt-report)。1. 用于生成HTML报告使用。请注意,BIRT 生成 HTML 而不是 GSP。您可以在 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
}
Run Code Online (Sandbox Code Playgroud)
生成 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() 返回 false }
归档时间: |
|
查看次数: |
1581 次 |
最近记录: |