Skip to content

Instantly share code, notes, and snippets.

@hjzheng
Created August 28, 2017 09:55
Show Gist options
  • Save hjzheng/4e1c452b0a392ca67502c0c8642f674a to your computer and use it in GitHub Desktop.
Save hjzheng/4e1c452b0a392ca67502c0c8642f674a to your computer and use it in GitHub Desktop.
前端导出 Excel 表格,数字格式,通过样式进行处理
.num {
  mso-number-format:General;
}
.text{
  mso-number-format:"\@";/*force text*/
}
<td class="num">34</td>
<td class="num">17.0</td>
<td class="text">067</td>

https://stackoverflow.com/questions/354476/html-to-excel-how-can-tell-excel-to-treat-columns-as-numbers/354574#354574

其他格式:

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) 
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment