|
1 | | -# JexcelAngular |
2 | | - |
3 | | -This project was generated with [Angular CLI](https://github.com/angular/angular-cli) version 9.1.0. |
4 | | - |
5 | | -## Development server |
6 | | - |
7 | | -Run `ng serve` for a dev server. Navigate to `http://localhost:4200/`. The app will automatically reload if you change any of the source files. |
8 | | - |
9 | | -## Code scaffolding |
10 | | - |
11 | | -Run `ng generate component component-name` to generate a new component. You can also use `ng generate directive|pipe|service|class|guard|interface|enum|module`. |
12 | | - |
13 | | -## Build |
14 | | - |
15 | | -Run `ng build` to build the project. The build artifacts will be stored in the `dist/` directory. Use the `--prod` flag for a production build. |
16 | | - |
17 | | -## Running unit tests |
18 | | - |
19 | | -Run `ng test` to execute the unit tests via [Karma](https://karma-runner.github.io). |
20 | | - |
21 | | -## Running end-to-end tests |
22 | | - |
23 | | -Run `ng e2e` to execute the end-to-end tests via [Protractor](http://www.protractortest.org/). |
24 | | - |
25 | | -## Further help |
26 | | - |
27 | | -To get more help on the Angular CLI use `ng help` or go check out the [Angular CLI README](https://github.com/angular/angular-cli/blob/master/README.md). |
| 1 | +# Jexcel with Angular |
| 2 | + |
| 3 | +## Style |
| 4 | + |
| 5 | +Make sure import the CSS and JS classes in your angular.json file |
| 6 | + |
| 7 | +"styles": [ |
| 8 | + ... |
| 9 | + "./node_modules/jexcel/dist/jexcel.css" |
| 10 | + ], |
| 11 | + "scripts": [ |
| 12 | + "./node_modules/jexcel/dist/jexcel.js" |
| 13 | + ] |
| 14 | + |
| 15 | +## HTML FILE |
| 16 | + |
| 17 | +<div #spreadsheet></div> |
| 18 | + |
| 19 | + |
| 20 | +## Typescript file |
| 21 | + |
| 22 | +import { Component, OnInit, ViewChild, ElementRef, AfterViewInit } from '@angular/core'; |
| 23 | +import * as jexcel from 'jexcel'; |
| 24 | +@Component({ |
| 25 | + selector: 'app-jexcel-spreadsheet', |
| 26 | + templateUrl: './jexcel-spreadsheet.component.html', |
| 27 | + styleUrls: ['./jexcel-spreadsheet.component.css'] |
| 28 | +}) |
| 29 | +export class JexcelSpreadsheetComponent implements OnInit, AfterViewInit{ |
| 30 | + @ViewChild('spreadsheet') spreadsheet: ElementRef; |
| 31 | + constructor() { } |
| 32 | + |
| 33 | + data = [ |
| 34 | + ['Mazda', 2001, 2000], |
| 35 | + ['Pegeout', 2010, 5000], |
| 36 | + ['Honda Fit', 2009, 3000], |
| 37 | + ['Honda CRV', 2010, 6000], |
| 38 | +]; |
| 39 | + |
| 40 | + ngOnInit(): void { |
| 41 | + |
| 42 | + } |
| 43 | + |
| 44 | + ngAfterViewInit() { |
| 45 | + jexcel(this.spreadsheet.nativeElement, { |
| 46 | + data: this.data, |
| 47 | + columns: [ |
| 48 | + { title: 'Model', width: 300 }, |
| 49 | + { title: 'Price', width: 80 }, |
| 50 | + { title: 'Model', width: 100 } |
| 51 | + ], |
| 52 | + minDimensions: [10, 10] |
| 53 | + }); |
| 54 | + } |
| 55 | +} |
0 commit comments