diff --git a/src/app/app.component.ts b/src/app/app.component.ts index 7e8f0ae..c240ec1 100644 --- a/src/app/app.component.ts +++ b/src/app/app.component.ts @@ -1,32 +1,26 @@ -import { Component } from '@angular/core'; +import { Component, ElementRef, ViewChild } from '@angular/core'; +import { DomSanitizer, SafeHtml } from '@angular/platform-browser'; +import { read, utils } from 'xlsx'; @Component({ selector: 'app-root', - template: ` - -
-

- Welcome to {{title}}! -

- {{ title }} app is running! - Angular Logo -
-

Here are some links to help you start:

-
    -
  • -

    Tour of Heroes

    -
  • -
  • -

    CLI Documentation

    -
  • -
  • -

    Angular blog

    -
  • -
- - `, - styles: [] + template: `
` }) export class AppComponent { - title = 'sheetjs-angular'; + constructor(private sanitizer: DomSanitizer) {} + html: SafeHtml = ""; + @ViewChild('tableau') tabeller!: ElementRef; + ngOnInit(): void { (async() => { + /* Download from https://sheetjs.com/pres.numbers */ + const f = await fetch("/assets/write.dbf"); + const ab = await f.arrayBuffer(); + + /* parse workbook */ + const wb = read(ab); + + /* update data */ + const h = utils.sheet_to_html(wb.Sheets[wb.SheetNames[0]]); + this.html = this.sanitizer.bypassSecurityTrustHtml(h); + })(); } } +