I have the problem when I download the file.
I download the file with this text:
PK
z—LO‹Ý< _rels/.rels<?xml version="1.0" encoding="UTF-8"?><Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships"><Relationship Target="word/document.xml" Id="pkgRId0" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument" /></Relationships>PK
z—LÜó À– – word/_rels/document.xml.rels<?xml version="1.0" encoding="UTF-8"?><Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships"><Relationship Target="numbering.xml" Id="docRId0" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/numbering" /><Relationship Target="styles.xml" Id="docRId1" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/styles" /></Relationships>PK
c…˜Lx»s/ / word/document.xml<?xml version="1.0" encoding="UTF-8" standalone="yes"?><w:document xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main"><w:body><w:p><w:pPr><w:spacing w:before="0" w:after="200" w:line="276" /><w:ind w:right="0" w:left="0" w:firstLine="0" /><w:jc w:val="left" /><w:rPr><w:rFonts w:ascii="Calibri" w:hAnsi="Calibri" w:cs="Calibri" w:eastAsia="Calibri" /><w:color w:val="auto" /><w:spacing w:val="0" /><w:position w:val="0" /><w:sz w:val="24" /><w:shd w:fill="auto" w:val="clear" /></w:rPr></w:pPr><w:r><w:rPr><w:rFonts w:ascii="Calibri" w:hAnsi="Calibri" w:cs="Calibri" w:eastAsia="Calibri" /><w:color w:val="auto" /><w:spacing w:val="0" /><w:position w:val="0" /><w:sz w:val="72" /><w:shd w:fill="auto" w:val="clear" /></w:rPr><w:t xml:space="preserve">test</w:t></w:r></w:p></w:body></w:document>PK
z—L,1¿q word/numbering.xml<?xml version="1.0" encoding="UTF-8" standalone="yes"?><w:numbering xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main" />PK
z—L¯SÈAŠ Š word/styles.xml<?xml version="1.0" encoding="UTF-8" standalone="yes"?><w:styles xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main" />PK
z—Lÿbkº] ] [Content_Types].xml<?xml version="1.0" encoding="UTF-8"?><Types xmlns="http://schemas.openxmlformats.org/package/2006/content-types"><Default Extension="rels" ContentType="application/vnd.openxmlformats-package.relationships+xml" /><Default Extension="xml" ContentType="application/vnd.openxmlformats-officedocument.wordprocessingml.document.main+xml" /><Override PartName="/word/numbering.xml" ContentType="application/vnd.openxmlformats-officedocument.wordprocessingml.numbering+xml" /><Override PartName="/word/styles.xml" ContentType="application/vnd.openxmlformats-officedocument.wordprocessingml.styles+xml" /></Types>PK
c…˜L word/PK
z—LO‹Ý< _rels/.relsPK
z—LÜó À– – E word/_rels/document.xml.relsPK
c…˜Lx»s/ / word/document.xmlPK
z—L,1¿q s word/numbering.xmlPK
z—L¯SÈAŠ Š 0 word/styles.xmlPK
z—Lÿbkº] ] ç [Content_Types].xmlPK
c…˜L u word/PK ³
In fact this is not the text that I want to download.
I tried this code: my service code:
public download(id: string): Observable<any> {
let params = new URLSearchParams();
let headers = new Headers();
headers.append('x-access-token', this.auth.getCurrentUser().token);
headers.append('sale_id', id);
headers.append('Content-Type', 'text/xml');
headers.append('responseType', 'blob');
return this.http.get(Api.getUrl(Api.URLS.download), {
headers: headers,
responseType: ResponseContentType.Blob,
}).map(res => res.blob())
}
my component code:
exportExcel(id: string) {
this.ss.download(id)
.subscribe(data => { console.log(`excel data: ${data}`); FileSaver.saveAs(data, 'people-export.xlsx') },
error => console.log("Error downloading the file."),
() => console.log('Completed file download.'));
}
my html code:
<button>
<i class="fa fa-save" aria-hidden="true"(click)="exportExcel(item.sale_id)"></i>
</button>
Please, I need your support. Thank you