レポートビューワー:FlexReportレポート

このサンプルは、Wijmo ReportViewerコントロールでC1 Web APIレポートサービスからFlexReportレポートを表示する方法を示します。

import 'bootstrap.css'; import '@grapecity/wijmo.styles/wijmo.css'; import './styles.css'; // import * as viewer from '@grapecity/wijmo.viewer'; import { getReports } from './data'; // document.readyState === 'complete' ? init() : window.onload = init; // function init() { let reportViewer = new viewer.ReportViewer('#reportViewer', { serviceUrl: 'https://demo.grapecity.com/c1/aspnet/c1webapi/4.0.20172.105/api/report' }); let lbReports = document.querySelector('#reports'); lbReports.addEventListener('change', () => loadReport()); // // fill reports list fillReportList(getReports()); loadReport(); // function fillReportList(reports) { let selCat = reports.selectedReport.categoryName, selRep = reports.selectedReport.reportName; // reports.categories.forEach(cat => { let catName = cat.name, optGroup = createComboOptionGroup(cat.text); // cat.reports.forEach(rep => { let option = createComboOption(rep.reportTitle, `${catName}/${rep.fileName}*${rep.reportName}`); // option.selected = (catName === selCat && rep.reportName === selRep); optGroup.appendChild(option); }); // lbReports.appendChild(optGroup); }); } // function loadReport() { let info = lbReports.value.split('*'); reportViewer.filePath = 'ReportsRoot/' + info[0]; reportViewer.reportName = info[1]; reportViewer.paginated = true; } // function createComboOptionGroup(text) { let optGroup = document.createElement('optgroup'); optGroup.label = text; return optGroup; } // function createComboOption(text, value) { let option = document.createElement('option'); option.innerHTML = text; option.value = value; return option; } } <!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <title>Viewing FlexReport reports</title> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <!-- SystemJS --> <script src="node_modules/systemjs/dist/system.src.js"></script> <script src="systemjs.config.js"></script> <script> System.import('./src/app'); </script> </head> <body> <div class="container-fluid"> <div class="row report-names"> <label for="reports">FlexReportの選択:</label> <select id="reports" class="combobox"></select> </div> <div id="reportViewer"></div> </div> </body> </html> // export function getReports() { return { selectedReport: { categoryName: 'Japanese Reports', fileName: '複写伝票.flxr', reportName: '納品書01' }, categories: [ { name: 'Japanese Reports', text: '日本語レポート', reports: [ { fileName: '複写伝票.flxr', reportName: '納品書01', reportTitle: '納品書' }, { fileName: 'レポート目次.flxr', reportName: 'レポート目次01', reportTitle: 'レポート目次' }, { fileName: '価格シール.flxr', reportName: '価格シール01', reportTitle: '価格シール' }, { fileName: '在庫管理.flxr', reportName: '商品管理02', reportTitle: '商品管理' }, { fileName: '社員名簿flxr', reportName: 'Employees レポート', reportTitle: '社員名簿' }, { fileName: '従業員別売上.flxr', reportName: '従業員別売上02', reportTitle: '従業員別売上' }, { fileName: '商品カタログ.flxr', reportName: '商品カタログ01', reportTitle: '商品カタログ' }, { fileName: '商品管理シール.flxr', reportName: '商品管理シール01', reportTitle: '商品管理シール' }, { fileName: '請求書.flxr', reportName: '請求書03', reportTitle: '請求書' }, { fileName: '売上一覧.flxr', reportName: '売り上げリスト', reportTitle: '売り上げリスト' }, { fileName: '複写伝票.flxr', reportName: '納品書01', reportTitle: '納品書' }, { fileName: '連続帳票.flxr', reportName: '連続帳票01', reportTitle: '連続帳票' } ] } ] }; } body { margin-bottom: 24px; } label { margin-right: 3px; } .wj-viewer { width: 100%; display: block; } .report-names { margin: 10px; } @media print { .report-names { display: none; } } import 'bootstrap.css'; import '@grapecity/wijmo.styles/wijmo.css'; import './styles.css'; // import { Component, enableProdMode, NgModule } from '@angular/core'; import { FormsModule } from '@angular/forms'; import { platformBrowserDynamic } from '@angular/platform-browser-dynamic'; import { BrowserModule } from '@angular/platform-browser'; import { WjViewerModule } from '@grapecity/wijmo.angular2.viewer'; import { getReports, TReportCategory } from './app.data'; // @Component({ selector: 'app-component', templateUrl: 'src/app.component.html' }) export class AppComponent { categories: TReportCategory[]; filePath: string; reportName: string; // constructor() { let reports = getReports(), sr = reports.selectedReport; // this.categories = reports.categories; this.reportInfo = `${sr.categoryName}/${sr.fileName}*${sr.reportName}`; } // get reportInfo(): string { return `${this.filePath}*${this.reportName}`; } set reportInfo(value: string) { let info = value.split('*'); this.filePath = info[0]; this.reportName = info[1]; } } // @NgModule({ imports: [WjViewerModule, BrowserModule, FormsModule], declarations: [AppComponent], bootstrap: [AppComponent] }) export class AppModule { } // enableProdMode(); // Bootstrap application with hash style navigation and global services. platformBrowserDynamic().bootstrapModule(AppModule); <!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <title>Viewing FlexReport reports</title> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <!-- Polyfills --> <script src="node_modules/core-js/client/shim.min.js"></script> <script src="node_modules/zone.js/dist/zone.min.js"></script> <!-- SystemJS --> <script src="node_modules/systemjs/dist/system.js"></script> <script src="systemjs.config.js"></script> <script> // workaround to load 'rxjs/operators' from the rxjs bundle System.import('rxjs').then(function (m) { System.set(SystemJS.resolveSync('rxjs/operators'), System.newModule(m.operators)); System.import('./src/app.component'); }); </script> </head> <body> <app-component></app-component> </body> </html> <div class="container-fluid"> <div class="row report-names"> <label for="reports">FlexReportの選択:</label> <select id="reports" class="combobox" [(ngModel)]="reportInfo"> <ng-template ngFor let-cat [ngForOf]="categories"> <optgroup *ngIf="cat.reports" label="{{cat.text}}"> <option *ngFor="let rep of cat.reports" [value]="cat.name + '/' + rep.fileName + '*' + rep.reportName"> {{rep.reportTitle}} </option> </optgroup> </ng-template> </select> </div> <wj-report-viewer [serviceUrl]="'https://demo.grapecity.com/c1/aspnet/c1webapi/4.0.20172.105/api/report'" [filePath]="'ReportsRoot/' + filePath" [reportName]="reportName" [paginated]="true"> </wj-report-viewer> </div> export type TReport = { fileName: string; reportName: string; reportTitle: string; }; // export type TReportCategory = { name: string; text: string; reports: TReport[]; }; // export type TReports = { selectedReport: { categoryName: string; fileName: string; reportName: string; }; categories: TReportCategory[]; }; // export function getReports() { return <TReports>{ selectedReport: { categoryName: 'Japanese Reports', fileName: '複写伝票.flxr', reportName: '納品書01' }, categories: [ { name: 'Japanese Reports', text: '日本語レポート', reports: [ { fileName: '複写伝票.flxr', reportName: '納品書01', reportTitle: '納品書' }, { fileName: 'レポート目次.flxr', reportName: 'レポート目次01', reportTitle: 'レポート目次' }, { fileName: '価格シール.flxr', reportName: '価格シール01', reportTitle: '価格シール' }, { fileName: '在庫管理.flxr', reportName: '商品管理02', reportTitle: '商品管理' }, { fileName: '社員名簿flxr', reportName: 'Employees レポート', reportTitle: '社員名簿' }, { fileName: '従業員別売上.flxr', reportName: '従業員別売上02', reportTitle: '従業員別売上' }, { fileName: '商品カタログ.flxr', reportName: '商品カタログ01', reportTitle: '商品カタログ' }, { fileName: '商品管理シール.flxr', reportName: '商品管理シール01', reportTitle: '商品管理シール' }, { fileName: '請求書.flxr', reportName: '請求書03', reportTitle: '請求書' }, { fileName: '売上一覧.flxr', reportName: '売り上げリスト', reportTitle: '売り上げリスト' }, { fileName: '複写伝票.flxr', reportName: '納品書01', reportTitle: '納品書' }, { fileName: '連続帳票.flxr', reportName: '連続帳票01', reportTitle: '連続帳票' } ] } ] }; } body { margin-bottom: 24px; } label { margin-right: 3px; } .wj-viewer { width: 100%; display: block; } .report-names { margin: 10px; } @media print { .report-names { display: none; } } import 'bootstrap.css'; import '@grapecity/wijmo.styles/wijmo.css'; import './app.css'; // import * as React from 'react'; import * as ReactDOM from 'react-dom'; import * as wjViewer from '@grapecity/wijmo.react.viewer'; import { getReports } from './data'; class App extends React.Component { constructor(props) { super(props); this.reports = getReports(); this.categories = this.reports.categories; let selectedReport = this.reports.selectedReport; this.state = { filePath: `${selectedReport.categoryName}/${selectedReport.fileName}`, reportName: selectedReport.reportName, reportInfo: `${selectedReport.categoryName}/${selectedReport.fileName}*${selectedReport.reportName}` }; } render() { return <div className="container-fluid"> <div className="row report-names"> <label>FlexReportの選択:</label> <select id="reports" className="combobox" value={this.state.reportInfo} onChange={this.onReportInfoChanged.bind(this)}> {this.categories.map(function (cat) { return <optgroup key={cat.name} label={cat.text}> {cat.reports.map(function (rep) { return <option key={rep.fileName} value={cat.name + '/' + rep.fileName + '*' + rep.reportName}> {rep.reportTitle} </option>; })} </optgroup>; })} </select> </div> <wjViewer.ReportViewer filePath={'ReportsRoot/' + this.state.filePath} reportName={this.state.reportName} paginated={true} serviceUrl="https://demo.grapecity.com/c1/aspnet/c1webapi/4.0.20172.105/api/report"> </wjViewer.ReportViewer> </div>; } onReportInfoChanged(e) { let info = e.target.value.split('*'); this.setState({ filePath: info[0], reportName: info[1], reportInfo: info[0] + "*" + info[1] }); console.log("onReportInfoChanged " + info[0] + "||||" + info[1]); } } ReactDOM.render(<App />, document.getElementById('app')); <!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <title>GrapeCity Wijmo FlexGrid Column DataMaps</title> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <!-- SystemJS --> <script src="node_modules/systemjs/dist/system.src.js"></script> <script src="systemjs.config.js"></script> <script> System.import('./src/app'); </script> </head> <body> <div id="app"></div> </body> </html> body { margin-bottom: 24px; } label { margin-right: 3px; } .container-fluid .wj-viewer { width: 100%; display: block; } .report-names { margin: 10px; } @media print { .report-names { display: none; } } export function getReports() { return { selectedReport: { categoryName: 'Japanese Reports', fileName: '複写伝票.flxr', reportName: '納品書01' }, categories: [ { name: 'Japanese Reports', text: '日本語レポート', reports: [ { fileName: '複写伝票.flxr', reportName: '納品書01', reportTitle: '納品書' }, { fileName: 'レポート目次.flxr', reportName: 'レポート目次01', reportTitle: 'レポート目次' }, { fileName: '価格シール.flxr', reportName: '価格シール01', reportTitle: '価格シール' }, { fileName: '在庫管理.flxr', reportName: '商品管理02', reportTitle: '商品管理' }, { fileName: '社員名簿flxr', reportName: 'Employees レポート', reportTitle: '社員名簿' }, { fileName: '従業員別売上.flxr', reportName: '従業員別売上02', reportTitle: '従業員別売上' }, { fileName: '商品カタログ.flxr', reportName: '商品カタログ01', reportTitle: '商品カタログ' }, { fileName: '商品管理シール.flxr', reportName: '商品管理シール01', reportTitle: '商品管理シール' }, { fileName: '請求書.flxr', reportName: '請求書03', reportTitle: '請求書' }, { fileName: '売上一覧.flxr', reportName: '売り上げリスト', reportTitle: '売り上げリスト' }, { fileName: '複写伝票.flxr', reportName: '納品書01', reportTitle: '納品書' }, { fileName: '連続帳票.flxr', reportName: '連続帳票01', reportTitle: '連続帳票' } ] } ] }; } <template> <div class="container-fluid"> <div class="row report-names"> <label for="reports">FlexReportの選択:</label> <select id="reports" class="combobox" v-model="reportInfo"> <optgroup v-for="cat in categories" :key="cat.name" :label="cat.text"> <option v-for="rep in cat.reports" :key="rep.fileName" :value="cat.name + '/' + rep.fileName + '*' + rep.reportName"> {{rep.reportTitle}} </option> </optgroup> </select> </div> <wj-report-viewer serviceUrl="https://demo.grapecity.com/c1/aspnet/c1webapi/4.0.20172.105/api/report" :filePath="'ReportsRoot/' + filePath" :reportName="reportName" :paginated=true> </wj-report-viewer> </div> </template> <script> import 'bootstrap.css'; import '@grapecity/wijmo.styles/wijmo.css'; import Vue from 'vue'; import '@grapecity/wijmo.vue2.viewer'; import { getReports } from './data'; // new Vue({ el: '#app', data: { categories: null, filePath: '', reportName: '' }, computed: { reportInfo: { get() { return `${this.filePath}*${this.reportName}`; }, set(value) { let info = value.split('*'); this.filePath = info[0]; this.reportName = info[1]; } } }, created() { let reports = getReports(), sr = reports.selectedReport; // this.categories = reports.categories; this.reportInfo = `${sr.categoryName}/${sr.fileName}*${sr.reportName}`; } }); </script> <style> body { margin-bottom: 24px; } label { margin-right: 3px; } .container-fluid .wj-viewer { width: 100%; display: block; } .report-names { margin: 10px; } @media print { .report-names { display: none; } } </style> <!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <title>Viewing FlexReport reports</title> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <!-- SystemJS --> <script src="node_modules/systemjs/dist/system.src.js"></script> <script src="systemjs.config.js"></script> <script> System.import('./src/app.vue'); </script> </head> <body> <div id="app"></div> </body> </html> export function getReports() { return { selectedReport: { categoryName: 'Japanese Reports', fileName: '複写伝票.flxr', reportName: '納品書01' }, categories: [ { name: 'Japanese Reports', text: '日本語レポート', reports: [ { fileName: '複写伝票.flxr', reportName: '納品書01', reportTitle: '納品書' }, { fileName: 'レポート目次.flxr', reportName: 'レポート目次01', reportTitle: 'レポート目次' }, { fileName: '価格シール.flxr', reportName: '価格シール01', reportTitle: '価格シール' }, { fileName: '在庫管理.flxr', reportName: '商品管理02', reportTitle: '商品管理' }, { fileName: '社員名簿flxr', reportName: 'Employees レポート', reportTitle: '社員名簿' }, { fileName: '従業員別売上.flxr', reportName: '従業員別売上02', reportTitle: '従業員別売上' }, { fileName: '商品カタログ.flxr', reportName: '商品カタログ01', reportTitle: '商品カタログ' }, { fileName: '商品管理シール.flxr', reportName: '商品管理シール01', reportTitle: '商品管理シール' }, { fileName: '請求書.flxr', reportName: '請求書03', reportTitle: '請求書' }, { fileName: '売上一覧.flxr', reportName: '売り上げリスト', reportTitle: '売り上げリスト' }, { fileName: '複写伝票.flxr', reportName: '納品書01', reportTitle: '納品書' }, { fileName: '連続帳票.flxr', reportName: '連続帳票01', reportTitle: '連続帳票' } ] } ] }; }