[]
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 @mescius/activereportsjs-react@latest #yarn yarn add @mescius/activereportsjs-react@latest
Replace the content of src\index.css
with the following:
@import "@mescius/activereportsjs/styles/ar-js-ui.css"; @import "@mescius/activereportsjs/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 "@mescius/activereportsjs-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.