[英]how to break cell in excel using FileSaver library in angular2
this.exportAsExcelFile(this.result, 'Report');
// this.result: it is json object
// 'Report': file name
I have |我有 | (pipe) seperated string.
(管道)分隔的字符串。 It prints in one line see image for more info
它打印在一行中,请参阅图像了解更多信息
Finally i got answer.最后我得到了答案。 string should be like this:
字符串应该是这样的:
str = "line1 \r\n line2 \r\n line3";
this string is in column E and row 2 thats why i have wrote it like这个字符串在 E 列和第 2 行,这就是我写它的原因
this.wrapAndCenterCell(worksheet['E2']);
see below function:见下面的功能:
public exportAsExcelFile(json: any[], excelFileName: string): void {
const worksheet: XLSX.WorkSheet = XLSX.utils.json_to_sheet(json);
this.wrapAndCenterCell(worksheet['E2']); //
const workbook: XLSX.WorkBook ={Sheets:{'data':worksheet},SheetNames:
['data'] };
const excelBuffer: any = XLSXStyle.write(workbook, { bookType: 'xlsx',
type:
'buffer' });
this.saveAsExcelFile(excelBuffer, excelFileName);
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.