エクスポート

このサンプルでは、APIを使用して、レポートをPDFファイルおよびExcelファイルにエクスポートします。

<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8" /> <meta http-equiv="X-UA-Compatible" content="IE=edge" /> <title>ActiveReportsJSデモ</title> <meta name="viewport" content="width=device-width, initial-scale=1.0" /> <link rel="stylesheet" href="https://cdn.materialdesignicons.com/2.8.94/css/materialdesignicons.min.css" /> <script src="/activereportsjs/demos/arjs/dist/ar-js-core.js"></script> <script src="/activereportsjs/demos/arjs/dist/ar-js-viewer.js"></script> <script src="/activereportsjs/demos/arjs/dist/ar-js-pdf.js"></script> <script src="/activereportsjs/demos/arjs/dist/ar-js-xlsx.js"></script> <script src="/activereportsjs/demos/arjs/dist/ar-js-html.js"></script> <script src="/activereportsjs/demos/arjs-localization/dist/ar-js-locales.js"></script> <script src="$DEMOROOT$/lib/purejs/license.js"></script> <link href="https://fonts.googleapis.com/css2?family=Montserrat:ital,wght@0,300;0,400;0,500;0,600;0,700;1,400&display=swap" rel="stylesheet" /> <link rel="stylesheet" type="text/css" href="/activereportsjs/demos/arjs/styles/ar-js-ui.css" /> <link rel="stylesheet" type="text/css" href="/activereportsjs/demos/arjs/styles/ar-js-viewer.css" /> <link rel="stylesheet" type="text/css" href="app.css" /> </head> <body onload="load()"> <div class="container"> <div id="viewer-host"></div> <div id="controls"> <div class="line"> <button id="export-pdf" onclick="runPdf()">PDF出力</button> </div> <div class="line"> <button id="export-excel" onclick="runExcel()">Excel出力</button> </div> </div> </div> <script> function load() { viewer = new MESCIUS.ActiveReportsJS.ReportViewer.Viewer( "#viewer-host", { language: "ja" } ); MESCIUS.ActiveReportsJS.Core.FontStore.registerFonts("fonts/fontsConfig.json").then(function () { viewer.open("Quotation.rdlx-json"); }); } function runPdf() { var ARJS = MESCIUS.ActiveReportsJS.Core; var PDF = MESCIUS.ActiveReportsJS.PdfExport; var settings = { info: { title: "御見積書", author: "MESCIUS inc.", }, pdfVersion: "1.7" }; var pageReport = new ARJS.PageReport({ language: "ja" }); 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"); }); } function runExcel() { var ARJS = MESCIUS.ActiveReportsJS.Core; var Excel = MESCIUS.ActiveReportsJS.XlsxExport; var settings = { sheetName: "御見積書", pageSettings: { size: "A4", orientation: "portrait", }, }; var pageReport = new ARJS.PageReport({ language: "ja" }); 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"); }); } </script> </body> </html>