Bootstrap

layui单据打印_layer系列之table导出+打印功能总结

1.关于layui导出方式,直接使用layui(版本2.4.5及以上)自带的导出方法即可:

layui--layui-table导出Excel

立即转化为数据表格

将数据转化为静态表格

导出Excel

昵称加入时间签名

贤心12016-11-28人生就像是一场修行 A贤心22016-11-29人生就像是一场修行 B贤心32016-11-30人生就像是一场修行 C

var exportBillsData=[{

'nos':1,

'CompanyId':1001,

'CompanyName':"携程",

'Sex':'男'

},{

'nos':2,

'CompanyId':1002,

'CompanyName':"携程1",

'Sex':'女'

}];

layui.use('table', function(){

var table = layui.table;

});

//1.转化为静态表格-直接为layui-table绑定数据

function convertToTable(){

layui.use('table', function () {

var table = layui.table;

table.render({

elem: '#table_TravelagenceCheck'

, height: 480

, title: "协议贡献量明细"

, page: true

, size: 'sm'

, toolbar: "协议入住明细"

, defaultToolbar: ['filter', 'print', 'exports']

, limit: 200

, limits: [200]

//直接绑定data

, data: exportBillsData

, cols: [[ //表头

{ field: 'nos', title: "序号", width: '2%', type: 'numbers', unresize: true }

, { field: 'CompanyId', title: "协议编号", width: '10%', sort: true, unresize: true }

, { field: 'CompanyName', title: "协议名称", width: '12%', sort: true, unresize: true }

, { field: 'Sex', title: "性别", width: '12%', sort: true, unresize: true }

]]

});

});

}

//导出Excel-注明:table.exportFile方法是layui-table自带的,适用于2.4.5版本,2.3.0版本的layui.js没有这个方法

function exportToExcel(){

layui.use('table', function () {

var table = layui.table;

table.exportFile(["昵称", "加入时间", "签名"],[

['贤心1','2016-11-28','人生就像是一场修行 A'],

['贤心2','2019-11-28','人生就像是一场修行 B'],

['贤心3','2016-10-28','人生就像是一场修行 C']

],'本日将到订单列表.xls');

});

}

//导出Excel1

function exportToExcel1(){

layui.use('table', function () {

var table = layui.table;

table.exportFile(["#","账号", "类型", "姓名", "房型", "房号", "状态", "成交价",

"余额", "信用金额", "预付金额", "到达", "离开", "手机", "房数", "联房",

"VIP", "房价码", "市场码", "公司", "预订号", "备注"],[

['1','F1908090001','F','jackA302','三人房有窗 浪漫','A302','R','120','400','0','0','2019-08-09 09:33','2019-08-30 12:00','1734***2827','1','-','-','BASE','上门散客','-','R1908090001','-'],

['2','F1908210008','F','jackG202','双床房海景','G202','R','501','0','0','0','2019-08-22 09:16','2019-08-30 12:00','1734***2827','1','-','-','BASE','上门散客','-','R1908210003','-'],

['3','F1908210012','F','李先生/李先生','双床房海景','-','R','501','0','0','0','2019-08-22 12:00','2019-08-23 12:00','1777***3792','1','-','-','BASE','上门散客','-','R1908210004','-'],

['4','F1908210030','F','丁小

;