JS導出Excel,長數字串變成科學計數法的解決方案

本文轉載至:js導出excel表格中較長數字串會變成科學計數法問題,同時感謝原作者的整理與創作;

JS 導出成 Excel 時,遇到個問題:當單元格中的數字超過 11 位時,會自動變成科學計數法;

頁面上的原數據:
這裏寫圖片描述

導出成 Excel 後,單元格內的數據:
這裏寫圖片描述


解決方案:
在數字過長的數據列上加上這個樣式即可解決:
style="mso-number-format:'\@';"


其他單元格樣式:

CSS代碼 說明或示例
mso-number-format:”0” NO Decimals
mso-number-format:”0.000” 3 Decimals
mso-number-format:”#,##0.000” Comma with 3 dec
mso-number-format:”mm\/dd\/yy” Date7
mso-number-format:”mmmm\ d,\ yyyy” Date9
mso-number-format:”m\/d\/yy\ h:mm\ AM\/PM” D -T AMPM
mso-number-format:”Short Date” 01/03/1998
mso-number-format:”Medium Date” 01-mar-98
mso-number-format:”d-mmm-yyyy” 01-mar-1998
mso-number-format:”Short Time” 5:16
mso-number-format:”Medium Time” 5:16 am
mso-number-format:”Long Time” 5:16:21:00
mso-number-format:”Percent” Percent - two decimals
mso-number-format:”0%” Percent - no decimals
mso-number-format:”0.E+00” Scientific Notation
mso-number-format:”\@” Text
mso-number-format:”#\ ???\/???” Fractions - up to 3 digits (312/943)
mso-number-format:”\0022£\0022#,##0.00” £12.76
mso-number-format:”#,##0.00_ \;[Red]-#,##0.00\ “ 2 decimals, negative numbers in red and signed (1.56 -1.56)
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章