使用Cli alasql的Angular 5无法找到xlsx.js

时间:2018-03-08 08:36:19

标签: angular include command-line-interface xlsx alasql

来自JSON的xlsx与alasql和xlsx。我能够使用alasql生成xls,但xlsx生成失败。我将脚本添加到cli中,编译器没有错误。

当我调用执行渲染的genXlsx()函数时,我得到一个控制台错误: Error

StatsComponent.ts

import * as alasql from 'alasql';

export class StatsComponent {
  genXlsx(): void {   
    const data1 = [{ a: 1, b: 10 }, { a: 2, b: 20 }];
    const data2 = [{ a: 100, b: 10 }, { a: 200, b: 20 }];
    const opts = [{ sheetid: 'Good', header: true }, { sheetid: 'Two', header: false }];
    const res = alasql('SELECT INTO XLSX("MyAwesomeData.xlsx",?) FROM ?', [opts, [data1, data2]]);
  }
}

的package.json

"dependencies": {
    "@angular/animations": "^5.0.2",
    "@angular/common": "^5.0.2",
    "@angular/compiler": "^5.0.2",
    "@angular/core": "^5.0.2",
    "@angular/forms": "^5.0.2",
    "@angular/material": "^5.0.0-rc.1",
    "@angular/platform-browser": "^5.0.2",
    "@angular/platform-browser-dynamic": "^5.0.2",
    "@angular/router": "^5.0.2",
    "@ngx-translate/core": "^8.0.0",
    "@ngx-translate/http-loader": "^2.0.0",
    "@types/jspdf": "^1.1.31",
    "alasql": "^0.4.5",
    "bootstrap": "^3.3.7",
    "chart.js": "^2.7.1",
    "core-js": "^2.4.1",
    "font-awesome": "^4.7.0",
    "html2canvas": "^1.0.0-alpha.8",
    "jspdf": "^1.3.5",
    "responsive-directives-angular2": "^0.4.2",
    "rxjs": "^5.1.0",
    "xlsx": "^0.12.4",
    "zone.js": "^0.8.4"
  },
  "devDependencies": {
    "@angular/cli": "^1.7.3",
    "@angular/compiler-cli": "^5.0.2",
    "@compodoc/compodoc": "^1.0.5",
    "@types/jasmine": "2.8.2",
    "@types/node": "^8.0.58",
    "codelyzer": "~4.0.1",
    "jasmine-core": "~2.8.0",
    "jasmine-spec-reporter": "~4.2.1",
    "karma": "~1.7.1",
    "karma-chrome-launcher": "~2.2.0",
    "karma-cli": "~1.0.1",
    "karma-coverage-istanbul-reporter": "^1.3.0",
    "karma-jasmine": "~1.1.0",
    "karma-jasmine-html-reporter": "^0.2.2",
    "karma-phantomjs-launcher": "^1.0.4",
    "node-sass": "^4.7.2",
    "protractor": "~5.2.0",
    "sass-loader": "^6.0.6",
    "ts-node": "~3.3.0",
    "tslint": "~5.8.0",
    "typescript": "~2.6.1",
    "webpack": "^3.10.0"
  }

.angular-cli.json

 "scripts": [
    "../node_modules/xlsx/dist/xlsx.core.min.js",
    "../node_modules/jspdf/dist/jspdf.min.js",
    "../node_modules/chart.js/src/chart.js",
    "../node_modules/alasql/dist/alasql.min.js"
  ],

有人可以帮我吗?谢谢:))

0 个答案:

没有答案