Reputation:
I try to export my table to Csv Or Excel file. Content of header & body in my table is Persian.
"روز"
this is my code:
function bestWayToExport() {
var table = document.getElementById('tableCount');
var html = table.outerHTML;
window.open('data:application/vnd.ms-excel;UTF-8,' + escape(html));
}
Now, result is incorrect.
" %u0631%u0648%u0632 "
What to do?! (Please No NEGATIVE - to me!)
Upvotes: 0
Views: 3990
Reputation: 2131
Hi i found below code may help you to what you want
$("#btnExport").click(function (e) {
window.open('data:application/vnd.ms-excel,' + $('#dvData').html());
e.preventDefault();
});
body {
font-size: 12pt;
font-family: Calibri;
padding : 10px;
}
table {
border: 1px solid black;
}
th {
border: 1px solid black;
padding: 5px;
background-color:grey;
color: white;
}
td {
border: 1px solid black;
padding: 5px;
}
input {
font-size: 12pt;
font-family: Calibri;
}
<input type="button" id="btnExport" value=" Export Table data into Excel " />
<br/>
<br/>
<div id="dvData">
<table>
<tr>
<th>Column One</th>
<th>Column Two</th>
<th>Column Three</th>
</tr>
<tr>
<td>row1 Col1</td>
<td>row1 Col2</td>
<td>row1 Col3</td>
</tr>
<tr>
<td>row2 Col1</td>
<td>row2 Col2</td>
<td>row2 Col3</td>
</tr>
<tr>
<td>row3 Col1</td>
<td>row3 Col2</td>
<td><a href="http://www.jquery2dotnet.com/">http://www.jquery2dotnet.com/</a>
</td>
</tr>
</table>
</div>
reference
http://jsfiddle.net/lesson8/jWAJ7/light/
Upvotes: 1