首页 > 其他分享 >使用SheetJs导出Excel设置指定单元格格式

使用SheetJs导出Excel设置指定单元格格式

时间:2022-10-11 17:02:42浏览次数:80  
标签:utils 单元格 Excel SheetJs cell A2 ws https var

var tbl = document.getElementById('sheetjs');
var wb = XLSX.utils.table_to_book(tbl);


var ws = wb.Sheets["Sheet1"]; //  get the current sheet
console.log(ws["A2"].v); //  default v value '4.56'

ws["A2"].z = "$0.00"; //  format the cell

delete ws["A2"].w; // delete old formatted text if it exists
XLSX.utils.format_cell(ws["A2"]); // refresh cell

console.log(ws["A2"].w); // new formatted cell '$4.56'

 

参考网址:

https://www.cnblogs.com/kaidarwang/p/9449815.html

https://docs.sheetjs.com/docs/api/utilities

https://stackoverflow.com/questions/53085906/xlsx-utils-table-to-book-currency-coming-as-general

 

标签:utils,单元格,Excel,SheetJs,cell,A2,ws,https,var
From: https://www.cnblogs.com/hdwang/p/16779786.html

相关文章