Angular7:将数据导出到CSV

时间:2018-11-13 09:55:50

标签: angular csv angular7

我最近将项目从Angular 5迁移到Angular 7,同时安装angular5-csv时收到以下警告:

  

npm WARN angular5-csv@0.2.10需要一个对等体@ angular / core @ ^ 5.0.0,但未安装。您必须自己安装对等依赖项。   npm WARN angular5-csv@0.2.10需要一个对等体@ angular / http @ ^ 5.0.0,但没有安装。您必须自己安装对等依赖项。   npm WARN angular5-csv@0.2.10需要rxjs@^5.5.2的对等节点,但未安装。您必须自己安装对等依赖项。

package.json:

    "@angular/cdk": "^7.0.3",
    "@angular/common": "^7.0.3",
    "@angular/compiler": "^7.0.3",
    "@angular/core": "^7.0.3",
    "@angular/forms": "^7.0.3",
    "@angular/http": "^7.0.3",
    "@angular/material": "^7.0.3",
    "@angular/platform-browser": "^7.0.3",
    "@angular/platform-browser-dynamic": "^7.0.3",
    "@angular/router": "^7.0.3",
    "angular5-csv": "^0.2.10"

我现在应该使用angular5-csv的替代版本吗?

1 个答案:

答案 0 :(得分:1)

package.json:

"angular7-csv": "^0.2.12",

Angular7示例:

import { AngularCsv } from 'angular7-csv';

var data = [
  {
    name: "Test 1",
    age: 13,
    average: 8.2,
    approved: true,
    description: "using 'Content here, content here' "
  },
  {
    name: 'Test 2',
    age: 11,
    average: 8.2,
    approved: true,
    description: "using 'Content here, content here' "
  },
  {
    name: 'Test 4',
    age: 10,
    average: 8.2,
    approved: true,
    description: "using 'Content here, content here' "
  },
];

new AngularCsv(data, 'My Report');