纯JS集成报表系列教程2

添加导出按钮

ActiveReportsJS提供导出API,在实际的业务场景中,可以根据自己的需求进行自定义导出。

下面我们就来看看如何自定义添加导出按钮

1、ActiveReportsJS添加按钮API

viewer.toolbar.addItem();

2、导出API

导出Excel

function runExcel() {

           var ARJS = GC.ActiveReports.Core;

           var Excel = GC.ActiveReports.XlsxExport;

           var settings = {

               sheetName: '快递单',

               pageSettings: {

                   size:'A4',

                   orientation: 'portrait'

               }

           }

           var pageReport = new ARJS.PageReport();

           pageReport.load('Quotation.rdlx-json')

               .then(function() { return pageReport.run() })

               .then(function(pageDocument) { return Excel.exportDocument(pageDocument, settings) })

               .then(function(result) { result.download('arjs-excel') });

       }

导出PDF


function runPdf() {

            var ARJS = GC.ActiveReports.Core;

            var PDF = GC.ActiveReports.PdfExport;

            var settings = {

                info: {

                    title: '快递单',

                    author: 'GrapeCity inc.',

                },

                pdfVersion:"1.7"

            }

            var pageReport = new ARJS.PageReport();

            pageReport.load('Quotation.rdlx-json')

                .then(function() { return pageReport.run() })

                .then(function(pageDocument) { return PDF.exportDocument(pageDocument, settings) })

                .then(function(result) { result.download('arjs-pdf') });

        }

导出Html

function runHtml(){  

            var ARJS = GC.ActiveReports.Core;

            var html= GC.ActiveReports.HtmlExport;

            var pageReport = new ARJS.PageReport();

            pageReport.load('reports/MonthSurvey.rdlx-json')

                .then(function() { return pageReport.run() })

                .then(function(pageDocument) { return html.exportDocument(pageDocument) })

                .then(function(result) { result.download('arjs-html') });           

          }

**
3、工具栏添加导出按钮(导出 Excel、PDF、Html)**







    

    

    ActiveReportsJS sample

    

    

    

    

    

    

    

    

    

    

    

    

    

    

    



    

**4、预览展示
**
纯JS集成报表系列教程2_第1张图片

你可能感兴趣的:(纯JS集成报表系列教程2)