eligrey / eligrey/FileSaver.js

Problema de charset UTF-8

Open
#562 4 comments 0 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
22k
Forks
4.3k
PR merge metrics
No merged PRs in 30d

Description

Estou usando com Angular 7 e Typescript
Gera o arquivo *csv mas abre com esses erros de caracteres.
```
import { Component } from '@angular/core';
import * as fileSaver from 'file-saver';

@Component({
selector: 'ngx-cadastro-clientes',
styleUrls: ['./clientes.component.scss'],
templateUrl: './clientes.component.html',
})
export class ClientesComponent {

downloadCSV() {
const replacer = (key, value) => value === null ? '' : value;
const header = Object.keys(this.data[0]);
let csv = this.data.map(row => header.map(fieldName => JSON.stringify(row[fieldName], replacer)).join(';'));
csv.unshift(header.join(';'));
let csvArray = csv.join('\r\n');
var blob = new Blob([csvArray], { type: "text/csv;charset=utf-8" })
fileSaver.saveAs(blob, "clientes.csv");
}
}

```
![image](https://user-images.githubusercontent.com/25781425/58370091-e0bc8e00-7ed8-11e9-95b1-33ea9afc63dd.png)

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.