Visualize: Export Report
The following sample exports 10 pages of the report to a paginated Excel spreadsheet:
by Yuriy Bablyukh
HTML
<script type='text/javascript' src="http://localhost:8081/jasperserver-pro/client/visualize.js?_opt=false"></script>
<button id="exportToPdf">
Export to Pdf
</button>
<div id="container">
<div id="loading">
<p><img src="http://i.stack.imgur.com/FhHRx.gif" /> Please Wait</p>
</div>
</div>
JavaScript
visualize({
auth: {
name: "superuser",
password: "superuser"
}
}, function(v) {
var report = v.report({
resource: "/organizations/organization_1/reports/interactive/TableReport",
ignorePagination:false,
container: "#container",
success: function(data) {
$("#loading").hide();
},
error: handleError
});
$("#exportToPdf").click(function(){
report
.export({
outputFormat: "pdf",
ignorePagination: false
})
.done(function(link) {
window.open(link.href, '_blank'); // open new window to download report
})
.fail(handleError);
});
function handleError(err) {
console.log(err);
}
});