0.0.3 • Published 6 years ago

@qlee/ng-csv v0.0.3

Weekly downloads
3
License
-
Repository
-
Last release
6 years ago

NgCsv

Import Module

import { NgCsvModule } from '@qlee/ng-csv';

@NgModule({
  declarations: [],
  imports: [ NgCsvModule ],
  providers: [],
  bootstrap: []
})
export class AppModule { }

Upload csv

<button ngCsv (upload)="upload($event)">选择文件</button>
class Component {
  upload(data: Observable<any>) {
      data.pipe(
        scan((all: string[], row: any[]) => [...all, row], [])
      ).subscribe(rows => this.data = rows);
    }
}

Download

import { of } from 'rxjs';
import { NgCsvService } from '@qlee/ng-csv';

class Component {
  constructor(private ngCsvService: NgCsvService) {}
  
  download() {
      this.ngCsvService.download('test.csv', of({ name: 1, age: '222,asd' }, { name: 2 }));
  }
}