使用SheetJs導出Excel設置指定單元格格式

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

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章