Bootstrap Table
HTML
<link rel="stylesheet" href="https://rawgit.com/wenzhixin/bootstrap-table/master/src/bootstrap-table.css">
<script src="https://rawgit.com/wenzhixin/bootstrap-table/master/src/bootstrap-table.js"></script>
<script src="https://rawgit.com/wenzhixin/bootstrap-table/master/src/extensions/export/bootstrap-table-export.js"></script>
<div id="toolbar">
<select class="form-control">
<option value="">Export Basic</option>
<option value="all">Export All</option>
<option value="selected">Export Selected</option>
</select>
</div>
<table id="table"
data-toggle="table"
data-toolbar="#toolbar"
data-show-export="true"
data-url="/gh/get/response.json/wenzhixin/bootstrap-table/tree/master/docs/data/data1/">
<thead>
<tr>
<th data-field="state" data-checkbox="true"></th>
<th data-field="name">Name</th>
<th data-field="stargazers_count">Stars</th>
<th data-field="forks_count">Forks</th>
<th data-field="description">Description</th>
</tr>
</thead>
</table>
JavaScript
$(function () {
var $table = $('#table');
$('#toolbar').find('select').change(function () {
$table.bootstrapTable('refreshOptions', {
exportDataType: $(this).val()
});
});
});
onMsoNumberFormat = function(cell, row, col) {
if (row > 0 && col == 2) {
return "#\\,##0\\.00";
}
if (row > 0 && col == 3) {
return "\\@";
}
};
/**
* @preserve tableExport.jquery.plugin
*
* Copyright (c) 2015,2016 hhurz, https://github.com/hhurz/tableExport.jquery.plugin
* Original work Copyright (c) 2014 Giri Raj, https://github.com/kayalshri/
*
* Licensed under the MIT License, http://opensource.org/licenses/mit-license
*/
(function ($) {
$.fn.extend({
tableExport: function (options) {
var defaults = {
onMsoNumberFormat: onMsoNumberFormat,
consoleLog: false,
csvEnclosure: '"',
csvSeparator: ',',
csvUseBOM: true,
displayTableName: false,
escape: false,
excelstyles: [], // e.g. ['border-bottom', 'border-top', 'border-left', 'border-right']
fileName: 'tableExport',
htmlContent: false,
ignoreColumn: [],
ignoreRow:[],
jsonScope: 'all', // head, data, all
jspdf: {orientation: 'p',
unit: 'pt',
format: 'a4', // jspdf page format or 'bestfit' for autmatic paper format selection
margins: {left: 20, right: 10, top: 10, bottom: 10},
autotable: {styles: {cellPadding: 2,
rowHeight: 12,
fontSize: 8,
fillColor: 255, // color value or 'inherit' to use css background-color from html table
textColor: 50, // color value or 'inherit' to use css color from html table
fontStyle: 'normal', // normal, bold, italic, bolditalic or 'inherit' to use css font-weight and fonst-style from html table
...