jQuery Export table data with images to Excel
Images are taken as OLE in Excel and not exported
HTML
<button id="myButtonControlID">Export Table data into Excel</button>
<div id="divTableDataHolder">
<title>Demo for huge data</title>
<table>
<thead>
<tr>
<th colspan="5">
Demoe By <a href="http://codePattern.net/blog">CodePattern.net</a>
</th>
</tr>
</thead>
<tbody>
<tr>
<td>A</td>
<td>1</td>
<td><img src='http://codepattern.net/Blog/pics/CodepatternLogoN.png' alt=''/></td>
</tr>
<tr>
<td>b</td>
<td>2</td>
<td><img id="img" src='' alt=''/></td>
</tr>
<tr>
<td>c</td>
<td>3</td>
<td>text</td>
</tr>
</tbody>
</table>
</div>
CSS
table
{
border: 1px solid black;
}
th
{
border: 1px solid black;
padding: 5px;
background-color:skyblue;
color: white;
}
td
{
border: 1px solid black;
padding: 5px;
color: green;
}
JavaScript
$("[id$=myButtonControlID]").click(function(e) {
window.open('data:application/vnd.ms-excel,' + encodeURIComponent( $('div[id$=divTableDataHolder]').html()));
e.preventDefault();
});
document.getElementById("img").src =...