Plugin de Jquery que exporta una tabla HTML a JSON, CSV, TXT, o PDF y forzar al navegador a descargar el archivo generado.
MIT License
Plugin de Jquery que exporta una tabla HTML a JSON, CSV, TXT, o PDF y forzar al navegador a descargar el archivo generado.
Jquery plugin that exports an HTML table to JSON, CSV, TXT, or PDF and force the browser to download the generated file.
Puede descargar el archivo tableHTMLExport.js que esta en la carpeta src de este repositorioo o utilizar el CDN
You can download the tableHTMLExport.js file that is in the src folder of this repository or use the CDN
<script src="https://rawcdn.githack.com/FuriosoJack/TableHTMLExport/v2.0.0/src/tableHTMLExport.js"></script>
<table id="tableCompany">
<thead>
<tr>
<th>Company</th>
<th>Contact</th>
<th class='acciones'>Country</th>
</tr>
</thead>
<tbody>
<tr>
<td>Alfreds Futterkiste</td>
<td id="primero">Maria Anders</td>
<td class="acciones">Germany</td>
</tr>
<tr>
<td>Ernst Handel</td>
<td>Roland Mendel</td>
<td class="acciones">Austria</td>
</tr>
<tr>
<td>Island Trading</td>
<td>Helen Bennett</td>
<td>UK</td>
</tr>
<tr id="ultimo">
<td>Magazzini Alimentari Riuniti</td>
<td>Giovanni Rovelli</td>
<td>Italy</td>
</tr>
</tbody>
</table>
Ejemplo Funcional | Functional Example
$("#tableCompany").tableHTMLExport({type:'json',filename:'tablaLicencias.json',ignoreColumns:'.acciones,#primero',ignoreRows: '#ultimo'});
Resultado: tablaLicencias.json
{
"header": [
"Company",
"Contact"
],
"data": [
[
"Alfreds Futterkiste"
],
[
"Ernst Handel",
"Roland Mendel"
],
[
"Island Trading",
"Helen Bennett",
"UK"
]
]
}
$("#tableCompany").tableHTMLExport({type:'csv',filename:'tablaLicencias.csv',ignoreColumns:'.acciones,#primero',ignoreRows: '#ultimo'});
Resultado:
"Company","Contact"
"Alfreds Futterkiste","Ernst Handel","Roland Mendel"
"Island Trading","Helen Bennett"
"UK",
Ejemplo Funcional | Functional Example
Para exportar a PDF es requerido la libreria jsPDF-AutoTable To export to PDF the library is required jsPDF-AutoTable
$("#tableCompany").tableHTMLExport({type:'pdf',filename:'tablaLicencias.pdf',ignoreColumns:'.acciones,#primero',ignoreRows: '#ultimo'});
Resultado | Result: