グリッド:カスタムフォント

このサンプルでは、ドキュメントに独自フォントを埋め込む方法を示します。このサンプルでは、IPAexゴシックフォントをドキュメントに埋め込みます。

import 'bootstrap.css'; import '@grapecity/wijmo.styles/wijmo.css'; import './styles.css'; import * as grid from '@grapecity/wijmo.grid'; import * as gridPdf from '@grapecity/wijmo.grid.pdf'; import { getData } from './data'; // document.readyState === 'complete' ? init() : window.onload = init; // function init() { let flexGrid = new grid.FlexGrid('#flexGrid', { autoGenerateColumns: false, selectionMode: grid.SelectionMode.ListBox, headersVisibility: grid.HeadersVisibility.All, columns: [ { header: 'ID', binding: 'id' }, { header: '国', binding: 'country' }, { header: '商品', binding: 'product' }, { header: '値引', binding: 'discount', format: 'p1' }, { header: '有効', binding: 'active' } ], itemsSource: getData(5) }); // document.querySelector('#btnExport').addEventListener('click', () => { gridPdf.FlexGridPdfConverter.export(flexGrid, 'FlexGrid.pdf', { documentOptions: { header: { declarative: { text: '\t&[Page] / &[Pages]' } }, footer: { declarative: { text: '\t&[Page] / &[Pages]' } } }, embeddedFonts: [ { source: 'https://demo.grapecity.com/wijmo/sample/fonts/ipaexg.ttf', name: 'ipaexg', style: 'normal', weight: 'normal', sansSerif: true }, { source: 'resources/fira/FiraSans-Bold.ttf', name: 'fira', style: 'normal', weight: 'bold', sansSerif: true } ], styles: { cellStyle: { backgroundColor: '#ffffff', borderColor: '#c6c6c6', font: { family: 'ipaexg' } }, altCellStyle: { backgroundColor: '#f9f9f9' }, groupCellStyle: { backgroundColor: '#dddddd' }, headerCellStyle: { backgroundColor: '#eaeaea' } } }); }); } <!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <title>Using a custom font</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"> <!-- Export button --> <button class="btn btn-default" id="btnExport">エクスポート</button> <!-- FlexGrid --> <div id="flexGrid" class="grid"></div> </div> </body> </html> export function getData(count) { // data used to generate random items const countries = ['アメリカ', 'ドイツ', 'イギリス', '日本', 'イタリア', 'ギリシャ']; const products = ['ウィジェット', 'ガジェット', 'ツール']; // let data = []; // // add count items for (let i = 0; i < count; i++) { // constants used to create data items let countryId = Math.floor(Math.random() * countries.length), productId = Math.floor(Math.random() * products.length); // // create the item let item = { id: i, country: countries[countryId], product: products[productId], discount: Math.random() / 4, active: i % 4 == 0 }; // // add the item to the list data.push(item); } // return data; } body { margin-bottom: 24px; } .grid { margin-top: 20px; height: 200px; } import 'bootstrap.css'; import '@grapecity/wijmo.styles/wijmo.css'; import './styles.css'; // import * as grid from '@grapecity/wijmo.grid'; import * as gridPdf from '@grapecity/wijmo.grid.pdf'; // import { Component, Inject, enableProdMode, NgModule, ViewChild } from '@angular/core'; import { platformBrowserDynamic } from '@angular/platform-browser-dynamic'; import { BrowserModule } from '@angular/platform-browser'; import { DataService } from './app.data'; import { WjGridModule } from '@grapecity/wijmo.angular2.grid'; // @Component({ selector: 'app-component', templateUrl: 'src/app.component.html' }) export class AppComponent { data: any[]; @ViewChild('flexGrid') flexGrid: grid.FlexGrid; // constructor(@Inject(DataService) private dataService: DataService) { this.data = dataService.getData(5); } // export() { gridPdf.FlexGridPdfConverter.export(this.flexGrid, 'FlexGrid.pdf', { documentOptions: { header: { declarative: { text: '\t&[Page] / &[Pages]' } }, footer: { declarative: { text: '\t&[Page] / &[Pages]' } } }, embeddedFonts: [ { source: 'https://demo.grapecity.com/wijmo/sample/fonts/ipaexg.ttf', name: 'ipaexg', style: 'normal', weight: 'normal', sansSerif: true }, { source: 'resources/fira/FiraSans-Bold.ttf', name: 'fira', style: 'normal', weight: 'bold', sansSerif: true } ], styles: { cellStyle: { backgroundColor: '#ffffff', borderColor: '#c6c6c6', font: { family: 'ipaexg' } }, altCellStyle: { backgroundColor: '#f9f9f9' }, groupCellStyle: { backgroundColor: '#dddddd' }, headerCellStyle: { backgroundColor: '#eaeaea' } } }); } } // @NgModule({ imports: [WjGridModule, BrowserModule], declarations: [AppComponent], providers: [DataService], 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>Using a custom font</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"> <!-- Export button --> <button class="btn btn-default" (click)="export()">エクスポート</button> <!-- FlexGrid --> <wj-flex-grid class="grid" #flexGrid [autoGenerateColumns]="false" selectionMode="ListBox" headersVisibility="All" [itemsSource]="data"> <wj-flex-grid-column header="ID" binding="id"></wj-flex-grid-column> <wj-flex-grid-column header="国" binding="country"></wj-flex-grid-column> <wj-flex-grid-column header="商品" binding="product"></wj-flex-grid-column> <wj-flex-grid-column header="値引" binding="discount" format="p1"></wj-flex-grid-column> <wj-flex-grid-column header="有効" binding="active"></wj-flex-grid-column> </wj-flex-grid> </div> import { Injectable } from '@angular/core'; // @Injectable() export class DataService { // getData(count: number) { // data used to generate random items const countries = ['アメリカ', 'ドイツ', 'イギリス', '日本', 'イタリア', 'ギリシャ']; const products = ['ウィジェット', 'ガジェット', 'ツール']; // let data = []; // // add count items for (let i = 0; i < count; i++) { // constants used to create data items let countryId = Math.floor(Math.random() * countries.length), productId = Math.floor(Math.random() * products.length); // // create the item let item = { id: i, country: countries[countryId], product: products[productId], discount: Math.random() / 4, active: i % 4 == 0 }; // // add the item to the list data.push(item); } // return data; } } body { margin-bottom: 24px; } .grid { margin-top: 20px; height: 200px; } import "@grapecity/wijmo.styles/wijmo.css"; import "bootstrap.css"; import "./app.css"; // import * as React from 'react'; import * as ReactDOM from 'react-dom'; import * as wjcGrid from "@grapecity/wijmo.react.grid"; import * as gridPdf from "@grapecity/wijmo.grid.pdf"; import { getData } from "./data"; class App extends React.Component { constructor(props) { super(props); this.state = { data: getData(5) }; } render() { return <div className="container-fluid"> <button className="btn btn-default" onClick={this.exportPDF.bind(this)}>エクスポート</button> <wjcGrid.FlexGrid className="grid" autoGenerateColumns={false} selectionMode="ListBox" headersVisibility="All" itemsSource={this.state.data} initialized={this.initializeGrid.bind(this)}> <wjcGrid.FlexGridColumn header="ID" binding="id"></wjcGrid.FlexGridColumn> <wjcGrid.FlexGridColumn header="国" binding="country"></wjcGrid.FlexGridColumn> <wjcGrid.FlexGridColumn header="商品" binding="product"></wjcGrid.FlexGridColumn> <wjcGrid.FlexGridColumn header="値引" binding="discount" format="p1"></wjcGrid.FlexGridColumn> <wjcGrid.FlexGridColumn header="有効" binding="active"></wjcGrid.FlexGridColumn> </wjcGrid.FlexGrid> </div>; } initializeGrid(ctl) { this.flexGrid = ctl; } exportPDF() { gridPdf.FlexGridPdfConverter.export(this.flexGrid, 'FlexGrid.pdf', { documentOptions: { header: { declarative: { text: '\t&[Page] / &[Pages]' } }, footer: { declarative: { text: '\t&[Page] / &[Pages]' } } }, embeddedFonts: [ { source: 'https://demo.grapecity.com/wijmo/sample/fonts/ipaexg.ttf', name: 'ipaexg', style: 'normal', weight: 'normal', sansSerif: true }, { source: 'resources/fira/FiraSans-Bold.ttf', name: 'fira', style: 'normal', weight: 'bold', sansSerif: true } ], styles: { cellStyle: { backgroundColor: '#ffffff', borderColor: '#c6c6c6', font: { family: 'ipaexg' } }, altCellStyle: { backgroundColor: '#f9f9f9' }, groupCellStyle: { backgroundColor: '#dddddd' }, headerCellStyle: { backgroundColor: '#eaeaea' } } }); } } 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 OLAP Pivot Chart Overview</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; } .grid { margin-top: 20px; height: 200px; } export function getData(count) { // data used to generate random items const countries = ['アメリカ', 'ドイツ', 'イギリス', '日本', 'イタリア', 'ギリシャ']; const products = ['ウィジェット', 'ガジェット', 'ツール']; // let data = []; // // add count items for (let i = 0; i < count; i++) { // constants used to create data items let countryId = Math.floor(Math.random() * countries.length), productId = Math.floor(Math.random() * products.length); // // create the item let item = { id: i, country: countries[countryId], product: products[productId], discount: Math.random() / 4, active: i % 4 == 0 }; // // add the item to the list data.push(item); } // return data; } <template> <div class="container-fluid"> <!-- Export button --> <button class="btn btn-default" v-on:click="exportPDF">エクスポート</button> <!-- FlexGrid --> <wj-flex-grid class="grid" :autoGenerateColumns=false selectionMode="ListBox" headersVisibility="All" :itemsSource="data" :initialized="initializeGrid"> <wj-flex-grid-column header="ID" binding="id"></wj-flex-grid-column> <wj-flex-grid-column header="国" binding="country"></wj-flex-grid-column> <wj-flex-grid-column header="商品" binding="product"></wj-flex-grid-column> <wj-flex-grid-column header="値引" binding="discount" format="p1"></wj-flex-grid-column> <wj-flex-grid-column header="有効" binding="active"></wj-flex-grid-column> </wj-flex-grid> </div> </template> <script> import 'bootstrap.css'; import '@grapecity/wijmo.styles/wijmo.css'; import Vue from 'vue'; import { getData } from './data'; import { WjGridModule } from '@grapecity/wijmo.vue2.grid'; import * as gridPdf from '@grapecity/wijmo.grid.pdf'; new Vue({ el: '#app', data: { data: getData(5) }, methods:{ initializeGrid(ctl) { this.flexGrid = ctl; }, exportPDF() { gridPdf.FlexGridPdfConverter.export(this.flexGrid, 'FlexGrid.pdf', { documentOptions: { header: { declarative: { text: '\t&[Page] / &[Pages]' } }, footer: { declarative: { text: '\t&[Page] / &[Pages]' } } }, embeddedFonts: [ { source: 'https://demo.grapecity.com/wijmo/sample/fonts/ipaexg.ttf', name: 'ipaexg', style: 'normal', weight: 'normal', sansSerif: true }, { source: 'resources/fira/FiraSans-Bold.ttf', name: 'fira', style: 'normal', weight: 'bold', sansSerif: true } ], styles: { cellStyle: { backgroundColor: '#ffffff', borderColor: '#c6c6c6', font: { family: 'ipaexg' } }, altCellStyle: { backgroundColor: '#f9f9f9' }, groupCellStyle: { backgroundColor: '#dddddd' }, headerCellStyle: { backgroundColor: '#eaeaea' } } }); } } }); </script> <style> body { margin-bottom: 24px; } .grid { margin-top: 20px; height: 200px; } </style> <!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <title>Using a custom font</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 getData(count) { // data used to generate random items const countries = ['アメリカ', 'ドイツ', 'イギリス', '日本', 'イタリア', 'ギリシャ']; const products = ['ウィジェット', 'ガジェット', 'ツール']; // let data = []; // // add count items for (let i = 0; i < count; i++) { // constants used to create data items let countryId = Math.floor(Math.random() * countries.length), productId = Math.floor(Math.random() * products.length); // // create the item let item = { id: i, country: countries[countryId], product: products[productId], discount: Math.random() / 4, active: i % 4 == 0 }; // // add the item to the list data.push(item); } // return data; }