2016-06-28 7 views
1

Excelにhtmlテーブルをエクスポートします。Excel番号へのhtmlテーブルのエクスポートが日付になりました

表:

<div id="table"> 
<table> 
    <thead> 
     <tr> 
      <th>Column</th> 
      <th>Column</th> 
     </tr> 
    </thead> 
     <tbody id="tabbodyExp"> 
     <tr> 
      <th>2.5</th> 
      <th>2.6</th> 
     </tr> 
    </tbody> 
</table> 
</div> 

スクリプト:

$("#btnExport").click(function (e) { 
    window.open('data:application/vnd.ms-excel,' + $('#table').html()); 
    e.preventDefault(); 
}); 

しかし、Excelは日付を "2.5" というように書かれているすべての数字を回しています。それを止める方法はありますか、それとも "2,5"のような数字を書く必要がありますか?

答えて

0

scunliffeさんの投稿の回答が見つかりました:Format HTML table cell so that Excel formats as text?このポストによれば、この特別なCSSプロパティをテーブルセルに適用すると、数値として書式設定する代わりに値として文字列として扱われます(うまくいけばあなたの日付でも同じです):

mso-number-format:"\@"; /*force text*/ 
関連する問題