不多逼逼直接上代码 设置单元格格式
excel.setExportCellStyle(data, 'A1:F1', { //A1-F1是范围区间 s: { fill: { bgColor: { indexed: 64 }, fgColor: { rgb: "A9A9A9" } },//设置背景颜色 //设置居中 alignment: { horizontal: 'center', vertical: 'center' } } }, function(cell, newCell, row, config, currentRow, currentCol, fieldKey) { // 回调参数,cell:原有数据,newCell:根据批量设置规则自动生成的样式,row:所在行数据,config:传入的配置,currentRow:当前行索引,currentCol:当前列索引,fieldKey:当前字段索引 return newCell ; } );设置单元格宽度
var colConf = excel.makeColConfig({ //设置每列的宽度 'A': 100, 'B': 130, 'C': 100, 'D': 80, 'E': 80, 'F': 50 }, 80); //设置表格名称 excel.exportExcel({ sheet1: data }, '查控流水信息.xlsx', 'xlsx',{ extend: { '!cols': colConf } } );