deftdawg / jexcel-with-angular

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Jexcel with Angular

Style

Make sure import the CSS and JS classes in your angular.json file

"styles": [
  ...
  "./node_modules/jexcel/dist/jexcel.css"
],
"scripts": [
  "./node_modules/jexcel/dist/jexcel.js"
]

HTML FILE

<div #spreadsheet></div>

Typescript file

import { Component, OnInit, ViewChild, ElementRef, AfterViewInit } from '@angular/core';
import * as jexcel from 'jexcel';

@Component({
  selector: 'app-jexcel-spreadsheet',
  templateUrl: './jexcel-spreadsheet.component.html',
  styleUrls: ['./jexcel-spreadsheet.component.css']
});

export class JexcelSpreadsheetComponent implements OnInit, AfterViewInit {
  @ViewChild('spreadsheet') spreadsheet: ElementRef;
  constructor() { }

  var data = [
    ['Mazda', 2001, 2000],
    ['Pegeout', 2010, 5000],
    ['Honda Fit', 2009, 3000],
    ['Honda CRV', 2010, 6000],
];

  ngOnInit(): void {
  }

  ngAfterViewInit() {
    jexcel(this.spreadsheet.nativeElement, {
      data: this.data,
        columns: [
          { title: 'Model', width: 300 },
          { title: 'Price', width: 80 },
          { title: 'Model', width: 100 }
      ],
      minDimensions: [10, 10]
    });
  }
}

About


Languages

Language:TypeScript 78.0%Language:JavaScript 17.6%Language:HTML 3.6%Language:CSS 0.8%