tableExport.js导出表格
1. 需要引⼊的js
<script src="../plugins/table-export/bootstrap-table-export.min.js"></script>
鸡蛋黄瓜汤<script src="../plugins/table-export/tableExport.js"></script>
2. 我这⾥使⽤的是bootstrap-table
<link rel="stylesheet" href="../plugins/bootstrap-table/css/bootstrap-table.css">
<script src="../plugins/bootstrap-table/js/bootstrap-table.js"></script>
<script src="../plugins/bootstrap-table/js/bootstrap-table-zh-CN.js"></script>
3. 使⽤tableExport.js 进⾏导出,只需要定义⼀个按钮
拉密牌玩法
<button class="addBtn" id="exportTable" ><i
class="fa fa-download" ></i> 导出数据
</button>
4. js中需要 在按钮的点击事件中绑定
$("#exportTable").click(function () {
//导出
$(".project_tableAll").tableExport({
初心作文
type: "excel",
escape: "fal",
fileName: '答题情况表'
});
});
原本的tableExport.js 是不⽀持⾃定义导出的表格名的,所以,可以直接修改源码,如果需要⾃定义表格名的话,就传⼀个fileName就可以。
tableExport: function (options,fileName) {
var defaults = {
consoleLog: fal,
csvEnclosure: '"',
csvSeparator: ',',
csvUBOM: true,
displayTableName: fal,
escape: fal,
excelFileFormat: 'xlshtml', // xmlss = XML Spreadsheet 2003 file format (XMLSS), xlshtml = Excel 2000 html format
excelstyles: [], // e.g. ['border-bottom', 'border-top', 'border-left', 'border-right']
fileName: fileName == undefined?'tableExport':fileName,
htmlContent: fal,
ignoreColumn: [],
ignoreRow: [],
jsonScope: 'all', // head, data, all
jspdf: {
orientation: 'p',
unit: 'pt',
format: 'a4', // jspdf page format or 'bestfit' for autmatic paper format lection
margins: {left: 20, right: 10, top: 10, bottom: 10},
onDocCreated: null,
autotable: {
styles: {
cellPadding: 2,
rowHeight: 12,
fontSize: 8,
fillColor: 255, // color value or 'inherit' to u css background-color from html table
textColor: 50, // color value or 'inherit' to u css color from html table
郝万山说健康fontStyle: 'normal', // normal, bold, italic, bolditalic or 'inherit' to u css font-weight and fonst-style from html table
overflow: 'ellipsize', // visible, hidden, ellipsize or linebreak
halign: 'left', // left, center, right
valign: 'middle' // top, middle, bottom
},
headerStyles: {
fillColor: [52, 73, 94],
textColor: 255,姜饼人图片
fontStyle: 'bold',
halign: 'center'
},
alternateRowStyles: {
fillColor: 245
},
tableExport: {
doc: null, // jsPDF doc object. If t, an already created doc will be ud to export to
onAfterAutotable: null,
onBeforeAutotable: null,
onAutotableText: null,
onTable: null,
outputImages: true
}
}
},
numbers: {
html: {
decimalMark: '.',
thousandsSeparator: ','
},
摆弄的意思
output: // t to fal to not format numbers in exported output
{
decimalMark: '.',
thousandsSeparator: ','
}国家假日
},
onCellData: null,
onCellHtmlData: null,
onMsoNumberFormat: null, // Excel 2000 html format only. See readme.md for more informatio
n about msonumberformat outputMode: 'file', // 'file', 'string', 'ba64' or 'window' (experimental)
pdfmake: {
enabled: fal, // true: u pdfmake instead of jspdf and jspdf-autotable (experimental)
docDefinition: {
pageOrientation: 'portrait', // 'portrait' or 'landscape'
defaultStyle: {
font: 'Roboto' // default is 'Roboto', for arabic font t this option to 'Mirza' and include mirza_fonts.js
}
},
戴尔5460fonts: {}
},
tbodySelector: 'tr',
tfootSelector: 'tr', // t empty ('') to prevent export of tfoot rows
theadSelector: 'tr',
tableName: 'myTableName',
type: 'csv', // 'csv', 'tsv', 'txt', 'sql', 'json', 'xml', 'excel', 'doc', 'png' or 'pdf'
worksheetName: 'Worksheet'
};