2016-06-02 1 views
1

jqueryを使用してExcelにエクスポートしたいhtmlデータを持っています。 私のjqueryのコードは次のとおりです。なぜ特定のhtmlデータでエクスポートするときにExcelが正しくフォーマットされないのですか?

$("#btnExport").click(function (e) { 

var dd=<div> 
<table cellspacing="0" rules="all" border="1" style="bordercollapse:collapse;"> 
    <tr> 
     <th scope="col">FirstName</th> 
     <th scope="col">LastName</th> 
     <th scope="col">Gender</th> 
     <th scope="col">Team_Name</th> 
     <th scope="col">MobileNumber</th> 
     <th scope="col">Alternative_Number</th> 
    </tr> 
    <tr> 
     <td>Gautam</td><td>Naik</td> 
     <td>Male</td> 
     <td>CCI Internal</td> 
     <td>3537835522</td> 
     <td>8244225654</td> 
    </tr> 
<table> 
<div>;  


window.open('data:application/vnd.ms-excel,' + dd); 
//e.preventDefault(); 
}); 

これは、それはXSLファイルをダウンロードしますが、このデータが含まれているポイントに取り組んでいます。

enter image description here

私はそれは私に正しい出力を与えていたデータをエクセルへのHTMLデータを変換http://www.convertcsv.com/html-table-to-csv.htmに同じHTMLデータを渡してみましたつまり、私は私のjqueryの中で何をする必要がありますどのような変更 enter image description here

コードを動作させるには?

答えて

1

jqueryを使用して各tdの値を取得し、サーバーにajaxを使用してcsv形式でポストする必要があります。サーバでCSV値を書き込み、ファイルをExcelに変換

関連する問題