I have a table with 5 columns, considering that the first one has a selection box and the last one has a button to delete that particular line.
The question is that I want to export to Excel, in a file .xsl
, but without the first and last column, consisting only: ID
, name
and house
. See the export code below:
$("#export").click(function(e) {
var type = 'data:application/vnd.ms-excel';
var _div = document.getElementById('table_wrapper');
var _html = _div.outerHTML.replace(/ /g, '%20');
var a = document.createElement('a');
a.href = type + ', ' + _html;
a.download = 'export_got_' + Math.floor((Math.random() * 9999999) + 1000000) + '.xls';
a.click();
});
table, tbody{
border-style: solid;
border-width: 1px;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script><divid="table_wrapper">
<table cellspacing="5" cellpadding="0" bordercolor="#ccc" id="list">
<tbody>
<tr class="header">
<th><input id="checkBox" type="checkbox"></th>
<th> ID</th>
<th> name</th>
<th> house</th>
<th> action</th>
</tr>
<tr>
<td><input id="checkBox" type="checkbox"></td>
<td>1</td>
<td>Jon Snow</td>
<td>Stark</td>
<td><a href='#'>Eliminar</a></td>
</tr>
<tr>
<td><input id="checkBox" type="checkbox"></td>
<td>2</td>
<td>James</td>
<td>Lennister</td>
<td><a href='#'>Eliminar</a></td>
</tr>
<tr>
<td><input id="checkBox" type="checkbox"></td>
<td>3</td>
<td>Arya</td>
<td>Stark</td>
<td><a href='#'>Eliminar</a></td>
</tr>
<tr>
<td><input id="checkBox" type="checkbox"></td>
<td>4</td>
<td>Cercei </td>
<td>Lennister</td>
<td><a href='#'>Eliminar</a></td>
</tr>
<tr>
<td><input id="checkBox" type="checkbox"></td>
<td>5</td>
<td>Daenerys </td>
<td>Targaryen</td>
<td><a href='#'>Eliminar</a></td>
</tr>
</tbody>
</table>
</div>
<br />
<button id="export">XABLAU</button>
How can I generate a file .xls
omitting some columns?