[]
本节我们主要介绍了如何在React 框架中使用 ActiveReportsJS Viewer 控件来创建 Web应用。
必备文件
npm install create-react-app -g
或
yarn global add create-react-app
以下步骤创建 React 应用程序
create-react-app arjs-react
cd arjs-react
npm install @grapecity/activereports-react
或
yarn add @grapecity/activereports-react
将设计好的报表文件放到'public
' 文件夹下。
修改 'src/App.js' 文件导入所需的样式及脚本文件:
import React from 'react';
import '@grapecity/activereports/styles/ar-js-viewer.css';
import { Viewer } from '@grapecity/activereports-react';
import { PdfExport, HtmlExport, XlsxExport, Core } from '@grapecity/activereports';
class App extends React.Component {
_viewer = Viewer;
render() {
return (<div className="demo-app" style={{ height: '1000px'}} >
<Viewer
report={{ Uri: "InvoiceList.rdlx-json" }}
sidebarVisible={true} toolbarVisible zoom='100%' />
</div>);
}
}
export default App;
import { PdfExport, HtmlExport, XlsxExport, Core } from '@grapecity/activereports';
这些功能模块不需要加载Viewer就可执行导出功能。
npm start
或
yarn start
您将在浏览器中中查看到运行的应用程序(localhost:3000
)。