[{"id":"5efffa63-6bf4-4819-8af7-0f6b8e1c53a4","tags":[{"name":"new","color":"#ed7422","productId":"d699a6af-e150-4da3-ab30-25fd97934601","links":null,"id":"4d7b6a40-ab32-4c71-a381-58f3ffd2653e"}]},{"id":"dfd416a6-eef9-49a0-bb8b-2e739da5cc1c","tags":[{"name":"new","color":"#ed7422","productId":"d699a6af-e150-4da3-ab30-25fd97934601","links":null,"id":"4d7b6a40-ab32-4c71-a381-58f3ffd2653e"}]},{"id":"3b1e4fc6-fe58-48c3-b090-4335186ca05c","tags":[{"name":"upd","color":"#7e678a","productId":"d699a6af-e150-4da3-ab30-25fd97934601","links":null,"id":"fe610228-9cf6-417f-813a-dcbfd25406c3"}]},{"id":"7f93f7b9-9f7f-46b2-b05f-494017b34eae","tags":[{"name":"upd","color":"#7e678a","productId":"d699a6af-e150-4da3-ab30-25fd97934601","links":null,"id":"fe610228-9cf6-417f-813a-dcbfd25406c3"}]},{"id":"95079239-11e6-44bd-8e3f-4c5b9f8e172c","tags":[{"name":"new","color":"#ed7422","productId":"d699a6af-e150-4da3-ab30-25fd97934601","links":null,"id":"4d7b6a40-ab32-4c71-a381-58f3ffd2653e"}]},{"id":"43ece935-4016-4eb3-a3f8-5951257cb2a7","tags":[{"name":"upd","color":"#7e678a","productId":"d699a6af-e150-4da3-ab30-25fd97934601","links":null,"id":"fe610228-9cf6-417f-813a-dcbfd25406c3"}]},{"id":"b2fdc309-b91f-42a8-b6f5-5c04d366748e","tags":[{"name":"upd","color":"#7e678a","productId":"d699a6af-e150-4da3-ab30-25fd97934601","links":null,"id":"fe610228-9cf6-417f-813a-dcbfd25406c3"}]},{"id":"bb982598-dc4e-4495-884c-64f4338def46","tags":[{"name":"upd","color":"#7e678a","productId":"d699a6af-e150-4da3-ab30-25fd97934601","links":null,"id":"fe610228-9cf6-417f-813a-dcbfd25406c3"}]},{"id":"c632c625-e3a4-4a10-abfa-66bf4a2cd520","tags":[{"name":"upd","color":"#7e678a","productId":"d699a6af-e150-4da3-ab30-25fd97934601","links":null,"id":"fe610228-9cf6-417f-813a-dcbfd25406c3"}]},{"id":"8fc7bf9e-d24f-43cd-a915-6f8a991152c4","tags":[{"name":"new","color":"#ed7422","productId":"d699a6af-e150-4da3-ab30-25fd97934601","links":null,"id":"4d7b6a40-ab32-4c71-a381-58f3ffd2653e"}]},{"id":"7e488fdd-64d8-4c8f-9f96-7a9590f02070","tags":[{"name":"new","color":"#ed7422","productId":"d699a6af-e150-4da3-ab30-25fd97934601","links":null,"id":"4d7b6a40-ab32-4c71-a381-58f3ffd2653e"}]},{"id":"4d93a50e-208e-44ef-8ea6-8e81d4c8f339","tags":[{"name":"upd","color":"#7e678a","productId":"d699a6af-e150-4da3-ab30-25fd97934601","links":null,"id":"fe610228-9cf6-417f-813a-dcbfd25406c3"}]},{"id":"e77dbdc2-200d-4c9c-9bf7-907a453eccb0","tags":[{"name":"upd","color":"#7e678a","productId":"d699a6af-e150-4da3-ab30-25fd97934601","links":null,"id":"fe610228-9cf6-417f-813a-dcbfd25406c3"}]},{"id":"eecc4b5c-431b-4677-887b-a523a0d10cfd","tags":[{"name":"upd","color":"#7e678a","productId":"d699a6af-e150-4da3-ab30-25fd97934601","links":null,"id":"fe610228-9cf6-417f-813a-dcbfd25406c3"}]},{"id":"ba126ca3-9e37-4aed-b486-a79bd39b3d86","tags":[{"name":"new","color":"#ed7422","productId":"d699a6af-e150-4da3-ab30-25fd97934601","links":null,"id":"4d7b6a40-ab32-4c71-a381-58f3ffd2653e"}]},{"id":"5792319e-7207-4871-a69d-aa3b6eabad63","tags":[{"name":"upd","color":"#7e678a","productId":"d699a6af-e150-4da3-ab30-25fd97934601","links":null,"id":"fe610228-9cf6-417f-813a-dcbfd25406c3"}]},{"id":"eb1cc175-3766-46e9-9659-c125771a58d4","tags":[{"name":"upd","color":"#7e678a","productId":"d699a6af-e150-4da3-ab30-25fd97934601","links":null,"id":"fe610228-9cf6-417f-813a-dcbfd25406c3"}]},{"id":"212b23f1-4bfe-46f9-91cf-f24eca55418d","tags":[{"name":"new","color":"#ed7422","productId":"d699a6af-e150-4da3-ab30-25fd97934601","links":null,"id":"4d7b6a40-ab32-4c71-a381-58f3ffd2653e"}]}]
This guide will help you set up the ActiveReportsJS Report Viewer
component in a Vite.js React application
. Vite.js is a modern build tool that leverages native ES modules to optimize the development experience and produce efficient production builds.
To create a new Vite.js React application, use the create-vite starter kit by running the following command:
# npm 6.x
npm init vite arjs-vite-react-app --template react
# npm 7+, extra double-dash is needed
npm init vite arjs-vite-react-app -- --template react
#yarn
yarn create vite arjs-vite-react-app --template react
Install the ActiveReportsJS React Report Viewer Component
and its dependencies with the following command:
#npm
npm install @grapecity/activereports-react@latest
#yarn
yarn add @grapecity/activereports-react@latest
To set up ActiveReportsJS in your Vite.js React app, create a new file alias.js
in the root folder and add the following code:
import moment from "./node_modules/moment";
export const { fn, min, max, now, utc, unix, months,
isDate, locale, invalid, duration, isMoment, weekdays,
parseZone, localeData, isDuration, monthsShort, weekdaysMin,
defineLocale, updateLocale, locales, weekdaysShort, normalizeUnits,
relativeTimeRounding, relativeTimeThreshold, calendarFormat, ISO_8601
} = moment;
export default moment;
Update the vite.config.js
file in the root folder with the following content:
import { defineConfig } from "vite";
import react from "@vitejs/plugin-react";
import path from "path";
export default defineConfig({
plugins: [react()],
resolve: {
alias: [
{
find: /^moment$/,
replacement: path.resolve(__dirname, "./alias.js"),
},
{
find: /^gc-dv$/,
replacement: path.resolve(
__dirname,
"./node_modules/@grapecity/activereports/lib/node_modules/gc-dv.js"
),
},
{
find: /^\@grapecity\/ar-js-pagereport$/,
replacement: path.resolve(
__dirname,
"./node_modules/@grapecity/activereports/lib/node_modules/@grapecity/ar-js-pagereport.js"
),
},
{
find: /^barcodejs$/,
replacement: path.resolve(
__dirname,
"./node_modules/@grapecity/activereports/lib/node_modules/barcodejs.js"
),
},
],
},
});
Replace the content of src\index.css
with the following:
@import "@grapecity/activereports/styles/ar-js-ui.css";
@import "@grapecity/activereports/styles/ar-js-viewer.css";
#viewer-host {
width: 100%;
height: 100vh;
}
Create a new file named report.rdlx-json
in the public folder and add the following JSON
content:
{
"Name": "Report",
"Body": {
"ReportItems": [
{
"Type": "textbox",
"Name": "TextBox1",
"Value": "Hello, ActiveReportsJS Viewer",
"Style": {
"FontSize": "18pt"
},
"Width": "8.5in",
"Height": "0.5in"
}
]
}
}
Replace the content of src\App.jsx
with the following code:
import React from "react";
import "./App.css";
import { Viewer } from "@grapecity/activereports-react";
function App() {
return (
<div id="viewer-host">
<Viewer report={{ Uri: 'report.rdlx-json' }} />
</div>
);
}
export default App;
To run the application in development mode, execute the following command:
# npm
npm run dev
#yarn
yarn dev
If you encounter an error stating 'vite' is not recognized as an internal or external command, operable program or batch file, delete the node_modules
folder and reinstall the required packages using npm install
or yarn
. Then run npm run dev
or yarn dev
again.
When the application starts, the ActiveReportsJS Viewer component will be displayed, showing the text Hello, ActiveReportsJS Viewer
. Test the basic functionality using the toolbar buttons or by exporting the report to an available format.