首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >如何通过Jasper PHP/REST API部署报表(jrxml文件)?

如何通过Jasper PHP/REST API部署报表(jrxml文件)?
EN

Stack Overflow用户
提问于 2013-06-27 23:59:07
回答 2查看 6.7K关注 0票数 1

如何通过Jasper PHP/REST API将报告(jrxml文件)部署到Jasper Reports Server?

EN

Stack Overflow用户

发布于 2013-07-19 17:07:02

要上传jrxml文件,需要创建一个PROP_HAS_DATA = trueResourceDescriptor,并将jrxml内容插入到一个多部分的PUT请求中。

经过一段时间的研究和调查,我让它运行起来,并开发了一个易于使用的PHP类。

http://blog.flowl.info/2013/jasper-php-library-on-github/

要上传jrxml文件,此代码完成以下工作:

代码语言:javascript
复制
// Init the Jasper connection
require_once('Jasper/Jasper.php');
$jasper = new \Jasper\Jasper();
$jasper->login('jasperadmin', 'jasperadmin', 'jasper.host.com:8080');

// Create a Resource Descriptor object for the jrxml file
$jrxml = new \Jasper\JasperJrxml('/reports/test.jrxml');

// Upload the Resource Descriptor object with content
$jasper->createContent($jrxml, file_get_contents('templates/test.jrxml'));

要创建报告单元,请使用以下行:

代码语言:javascript
复制
// Datasource Resource Descriptor
$mongo = new \Jasper\JasperDatasource();
$mongo->setPropIsReference('true');
$mongo->setPropReferenceUri('/datasources/mongo_local_test');

// Put everything together and deploy the report
$report->addChildResource($mongo);
$report->addChildResource($jrxml);

// Want to see the Resource Descriptor of the Report Unit?
// true = pretty print
print_r($report->getXml(true));

// Create a the Report Unit
$jasper->createResource($report);
票数 1
EN
查看全部 2 条回答
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/17347906

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档