[{"id":"ffec8bd3-7aae-4594-9410-30d8f75cd1d8","tags":[]},{"id":"7f87098b-cd80-42f7-b7c9-7ae079678a7d","tags":[]},{"id":"ede32062-2e96-44f1-91be-e72dd30ff38b","tags":[]},{"id":"2ac89cad-34cb-48d7-8d48-3d6fd8cf8a6d","tags":[]},{"id":"f95a1044-eee9-4cc3-ad34-a6abc40b7147","tags":[]},{"id":"a279e56b-9235-4470-a356-4e399491a489","tags":[]},{"id":"02619332-218d-4596-a566-4d10101c2fea","tags":[]},{"id":"b8d38a00-4d21-48aa-97d8-897743942525","tags":[]},{"id":"5ab75a14-d8aa-434a-91b4-3a46c924cd43","tags":[]},{"id":"7e3bfaec-bbcf-44b0-b1e0-23fa8938b378","tags":[]},{"id":"653a143f-a896-4baf-973f-8e9ff7d1caeb","tags":[]},{"id":"e6d68977-a270-4159-98f6-e0fed88b9b9d","tags":[]},{"id":"2c9104de-dfae-4165-a88c-3c702a7498b9","tags":[]},{"id":"67b4ece0-e32a-4778-bf78-39885d155a08","tags":[]},{"id":"cb1e72ed-746e-4f16-9ddc-ca4399a854ed","tags":[]},{"id":"7e5f6b8f-e289-4005-a9f1-f2fd24314969","tags":[]},{"id":"0d965fbd-0dba-4f62-a51d-39d9d1b89801","tags":[]},{"id":"16ef7359-484c-49f7-b00e-7a33904c6766","tags":[]},{"id":"44f82afe-5243-44ad-9514-3efce2f99e92","tags":[]},{"id":"41be4710-f6ef-40f7-a217-760ca7ac6d8d","tags":[]},{"id":"fe917819-bfd3-4463-a493-308aae3c0466","tags":[]},{"id":"85372212-6e12-4968-bff8-f1de2b53dacb","tags":[]},{"id":"12f32f30-f5f0-4a05-bf43-f6a4fd759483","tags":[]},{"id":"b0d4f051-46f7-4d39-90c4-10ca9a143e6d","tags":[]},{"id":"78217127-2f7c-4c2a-b1e0-a6462c036af1","tags":[]},{"id":"74fa9231-f7cc-42d2-80b9-e9e345120845","tags":[]},{"id":"a9e33769-b100-486f-88c9-75826b6a641f","tags":[]},{"id":"7c1ad13d-649f-4b90-9929-6567e9cb70ce","tags":[]},{"id":"e84b6f40-5d38-4e83-8ed8-42b3b192effc","tags":[]},{"id":"2003fa15-8ff1-463f-b443-b07cdfddda15","tags":[]},{"id":"94428a30-1b4f-408f-b13c-a91956e8bc8b","tags":[]},{"id":"b4d5cb90-b917-4abb-9d72-dc8732531d6d","tags":[]},{"id":"cbf4614f-4e01-4057-977d-c09f6027773a","tags":[]},{"id":"4f0464ba-a76b-4420-acf9-6b301fe92eb5","tags":[]},{"id":"de092a26-237a-4b4a-a26b-219a08d58290","tags":[]},{"id":"5085c479-6416-4cb4-9b03-03e3cb5dfb49","tags":[]},{"id":"fa57bedb-7a35-43df-9bb0-11f75cb6b036","tags":[]},{"id":"0d296f98-2882-4f36-99ca-593d81c1ea2c","tags":[]},{"id":"8f8d76db-fcf1-4614-a69d-91fcaa8e4c06","tags":[]},{"id":"2d045589-5bdf-4ea9-9daf-79f0737f1a7d","tags":[]},{"id":"a1cb9471-cc43-421e-a27c-73a77ed2c076","tags":[]},{"id":"ba0d2930-0bc2-41e7-bfb6-f670ba248346","tags":[]},{"id":"d9001f98-5ff3-4daa-ad2b-ae1871d80280","tags":[]},{"id":"8aa00408-e544-4f85-af0c-844a89483b71","tags":[]},{"id":"ea9401b1-388f-4801-9a1e-c61c241eb266","tags":[]},{"id":"4013df1a-026b-4e3e-9a55-2d9aa67ae595","tags":[]},{"id":"15925a79-6794-4fd3-a1d3-1140dbb7c895","tags":[]},{"id":"602c67a6-e96b-40b4-9a3e-58d3a025ee79","tags":[]},{"id":"628a0d59-3012-4486-87ee-327769c3aade","tags":[]},{"id":"43174189-d292-441e-96d4-671cf41684af","tags":[]},{"id":"5bc3527a-fc3e-437b-b5b7-00de4df2a2e5","tags":[]},{"id":"95724458-648d-4e53-a7a0-1337147ba3f4","tags":[]},{"id":"718d9115-3748-4484-8de8-3ced6e6c9700","tags":[]},{"id":"96ee753e-323d-4c1d-9eef-cc6bbc49cfc5","tags":[]},{"id":"60915523-8425-4684-9091-aa61a5e128f8","tags":[]},{"id":"026e2b9d-c68b-4a6f-bcf3-81c9e561f72c","tags":[]},{"id":"8cd4c6c2-43c3-4eee-865e-7ff204686d95","tags":[]},{"id":"bafbd30c-cdea-48c5-ae61-35ca286807ae","tags":[]},{"id":"332d456f-ad33-4575-bc27-961f08e6e91a","tags":[]},{"id":"3d6a25a2-259b-4717-949d-ffd746bbd16f","tags":[]},{"id":"d9eafb77-36ca-4e7b-b5c0-a6af25f7688a","tags":[]},{"id":"1f4bdca8-96a1-4cd6-a28e-36f00c37f2b8","tags":[]},{"id":"cc6bd783-e124-4778-b33b-8d8bd684174b","tags":[]},{"id":"40c3a8e6-1851-4a07-92b5-e5dbe79bd947","tags":[]},{"id":"3e93722a-922b-4e74-b888-60aa9711e910","tags":[]},{"id":"330219a6-2d62-4311-b0f0-2a63e6494f52","tags":[]},{"id":"303ede1f-f050-4e6a-81f3-57f5fea3f023","tags":[]},{"id":"8dac0e10-8c23-4173-a81c-0ccc62ff2851","tags":[]},{"id":"5d34d850-ab62-411e-87c6-ae34b948837c","tags":[]},{"id":"a17002a8-d526-4bab-adba-1225ecefa9c2","tags":[]},{"id":"6565eed5-a7f1-4b4b-8e79-b1b3211e2844","tags":[]},{"id":"43db06fc-f088-456d-b629-da070ced97c4","tags":[]},{"id":"23cd309a-4aa2-42a6-9a07-93fc70cbcd4c","tags":[]},{"id":"a355851a-9db9-478e-a342-276cdf963ab0","tags":[]},{"id":"0ca21ed4-1c3a-454c-9fa9-ace10bb631f7","tags":[]},{"id":"9b4f0622-c977-419f-b7fa-08a06a822378","tags":[]},{"id":"9db64270-eb0d-4c10-a3bd-99019a61d88d","tags":[]},{"id":"deec10d3-1cdd-4cf8-9bf8-9dc83f5005c2","tags":[]},{"id":"840c76dd-1003-4004-9aed-2bb0f7f64bcf","tags":[]},{"id":"a896ba47-426f-40a9-b640-39c5ba2e833e","tags":[]},{"id":"08e827cd-7c35-4891-91eb-3dcd38b24497","tags":[]},{"id":"c1573d04-8739-4293-99c6-c67af3c268b6","tags":[]},{"id":"3bd2cf00-2478-4c5f-877d-c43d4055b6d5","tags":[]},{"id":"a2575396-489d-49ce-a64e-671618389234","tags":[]},{"id":"da7309ca-78d5-4ab0-bacd-bd3efb37052a","tags":[]},{"id":"4fa7027e-e3b8-4558-a6a2-3d82194aa902","tags":[]},{"id":"123eb75a-7345-4b9f-86d4-d9c5e26e4f23","tags":[]},{"id":"5be2a877-4210-4df5-b725-bcd0e4fff62a","tags":[]},{"id":"47369ff7-3c58-4bbc-95e1-731d5c860b6a","tags":[]},{"id":"09135abc-177b-40a8-b7dd-c07e17550524","tags":[]},{"id":"5d7d6a4c-7700-4677-b9de-1a2f61fc1b63","tags":[]},{"id":"f7a66b21-bc48-4605-861e-836d79687cd5","tags":[]},{"id":"47f3215b-40b9-48e4-a12b-a4ba57b4f5f9","tags":[]},{"id":"3384d245-3058-4404-986e-6bd7b5c2f98d","tags":[]},{"id":"0cd35bb9-2405-4276-a2d7-c2b2c185212c","tags":[]},{"id":"2546b319-a2ef-46ad-870e-49347241fd44","tags":[]},{"id":"ec2d5efc-2644-4822-a21c-896f3417c2cc","tags":[]},{"id":"2ff2e2d2-9733-44e7-a4a4-f730afef9cc1","tags":[]},{"id":"8dcf63fe-80b1-4c77-967a-74924e3fab78","tags":[]},{"id":"f3eae03a-f6a8-4d1d-89ff-e03d36b1e4f3","tags":[]},{"id":"7369af56-7540-4fa7-91ad-1aaafb9ce815","tags":[]},{"id":"fd21e178-20d8-4d8c-be94-7fc3427d67cc","tags":[]},{"id":"28ca9a0a-9c8d-41fe-a294-4f151b518c95","tags":[]},{"id":"bd1628a0-f262-443f-bebf-e01742ee14d8","tags":[]},{"id":"abb90f39-6fd8-4f77-9c21-f7deadebac6a","tags":[]},{"id":"21e95400-7799-43bd-8892-b671d5ee2ed6","tags":[]},{"id":"3f805309-bfc4-41b5-bae2-96531e437b1e","tags":[]},{"id":"50ee4772-5f4a-489e-bb4c-49384cb6603b","tags":[]},{"id":"b3873b71-a23a-4dda-baa5-c0a76c75efeb","tags":[]},{"id":"be07849b-cec2-4116-b2f3-94f78b5673f7","tags":[]},{"id":"e7b17b5c-48f0-48b7-96c8-bdfb1e496075","tags":[]},{"id":"ee0891ea-23db-48ec-951a-3b8795e1d343","tags":[]},{"id":"cff30e38-eb6c-4e5d-8b86-8925ada9ba8b","tags":[]},{"id":"4b211280-ff30-4820-9f7c-f11845c23742","tags":[]},{"id":"13ca98f6-307a-42cf-8866-a88987905597","tags":[]}]
        
(Showing Draft Content)

在纯 JavaScript 应用中展示 ActiveReportsJS 报表

创建纯 JavaScript 应用

使用任意工具创建 HTML页面。 您可在任何文本编辑器中创建 HTML页面。 输入以下代码:

<!DOCTYPE html>

<html lang="en">
  <head>
    <meta charset="utf-8" />

    <title>ARJS Report Viewer</title>
    <meta name="description" content="ARJS Report viewer" />
    <meta name="author" content="GrapeCity" />
  </head>

  <body></body>
</html>

安装 ActivereportsJS

可直接从 CDN 和 NPM 引用 ActiveReportJS ,最简单的方法可直接引用 CDN 链接 head

<link
  rel="stylesheet"
  href="https://cdn.grapecity.com/activereportsjs/3.0.0/styles/ar-js-ui.css"
  type="text/css"
/>
<link
  rel="stylesheet"
  href="https://cdn.grapecity.com/activereportsjs/3.0.0/styles/ar-js-viewer.css"
  type="text/css"
/>
<script src="https://cdn.grapecity.com/activereportsjs/3.0.0/dist/ar-js-core.js"></script>
<script src="https://cdn.grapecity.com/activereportsjs/3.0.0/dist/ar-js-viewer.js"></script>
<script src="https://cdn.grapecity.com/activereportsjs/3.0.0/dist/ar-js-pdf.js"></script>
<script src="https://cdn.grapecity.com/activereportsjs/3.0.0/dist/ar-js-xlsx.js"></script>
<script src="https://cdn.grapecity.com/activereportsjs/3.0.0/dist/ar-js-html.js"></script>

添加报表 Viewer 宿主元素

body 标签中添加 div 元素

<div id="viewer-host"></div>

head 标签,添加 viewer-host 元素

<style>
  #viewer-host {
    margin: 0 auto;
    width: 100%;
    height: 100vh;
  }
</style>

初始化 报表Viewer组件

ActiveReportsJS 使用 JSON格式和rdlx-json扩展用于报表模板文件。在应用程序的根文件夹中,创建名为report.rdlx-json的新文件,并在该文件中插入以下JSON内容。


添加脚本代码:

{
  "Name": "Report",
  "Body": {
    "ReportItems": [
      {
        "Type": "textbox",
        "Name": "TextBox1",
        "Value": "Hello, ActiveReportsJS Viewer",
        "Style": {
          "FontSize": "18pt"
        },
        "Width": "8.5in",
        "Height": "0.5in"
      }
    ]
  }
}

初始化 报表Viewer组件

将以下脚本添加到body标签中的viewer-host元素之后,以便该脚本在呈现该元素之后运行。此代码初始化报表 Viewer实例,并在页面中加载报表文件。

<script>
  var viewer = new ActiveReports.Viewer("#viewer-host");
  viewer.open("report.rdlx-json");
</script>

运行并测试应用程序

您可以使用任何静态Web服务器来运行该应用程序。例如,http-server 包是全局安装的,则可以在应用程序的根文件夹中运行http-server命令来运行项目。确保您打开的地址为localhost(或127.0.0.1)上运行的应用程序。当应用程序启动时,ActiveReportsJS Viewer将出现在页面上。Viewer 将显示显示" Hello,ActiveReportsJS Viewer”文本的报表,您可以通过使用工具栏上的按钮或将报表导出为可用格式来测试基本功能。

相关链接