我无法以角度设置xlsx文档的工作表样式

时间:2019-04-22 13:24:49

标签: excel typescript npm xlsx exceljs

虽然我可以更改单元格的值,但不能在打字稿中设置单元格的样式。当我尝试更改它时,在excel中没有更改。我阅读了有关此文件,但找不到解决方法。

My code is like this:


        var worksheet: XLSX.WorkSheet = XLSX.utils.json_to_sheet(json);
        var cell = { s: {
                alignment: {textRotation: 90},
                font: {bold: true}
            },v: "SomeValue"
           };
        worksheet["B1"]= cell;

 var workbook: XLSX.WorkBook = { Sheets: { Liste: worksheet }, SheetNames: ['Liste'] };
        const excelBuffer: any = XLSX.write(workbook, { bookType: 'xlsx', type: 'array' });
        this.saveAsExcelFile(excelBuffer, excelFileName);

}

private saveAsExcelFile(buffer: any, fileName: string): void {
        const data: Blob = new Blob([buffer], { type: EXCEL_TYPE });
        FileSaver.saveAs(data, fileName + EXCEL_EXTENSION);
    }

Maybe, I couldn't put this script to the right file.
 <script lang="javascript" src="dist/xlsx.core.min.js"></script>

0 个答案:

没有答案