|
@@ -97,7 +97,7 @@ const XlsxPopulate = require('xlsx-populate');
|
|
|
rows = sheetData.rows,
|
|
rows = sheetData.rows,
|
|
|
sheet,
|
|
sheet,
|
|
|
cell = new Cell('A1'),
|
|
cell = new Cell('A1'),
|
|
|
- r, startCell, endCell, columnDatas, sheet_columns; // 当前第一列
|
|
|
|
|
|
|
+ r, startCell, endCell, columnDatas, sheet_columns, i; // 当前第一列
|
|
|
|
|
|
|
|
if(workbook.sheets().length - 1 < index) {
|
|
if(workbook.sheets().length - 1 < index) {
|
|
|
sheet = workbook.addSheet(sheetName)
|
|
sheet = workbook.addSheet(sheetName)
|
|
@@ -107,7 +107,7 @@ const XlsxPopulate = require('xlsx-populate');
|
|
|
|
|
|
|
|
if(header) {
|
|
if(header) {
|
|
|
startCell = cell;
|
|
startCell = cell;
|
|
|
- endCell = new Cell('A1').addCol(clen - 1);
|
|
|
|
|
|
|
+ endCell = new Cell('A1').addCol(clen - 2);
|
|
|
r = sheet.range(startCell + ":" + endCell).merged(true);
|
|
r = sheet.range(startCell + ":" + endCell).merged(true);
|
|
|
r.value(header);
|
|
r.value(header);
|
|
|
r.style({ fill: '70AD47', fontColor: 'ffffff', bold: true, horizontalAlignment: 'center', bottomBorder: true, bottomBorderColor: 'EAEAEA' });
|
|
r.style({ fill: '70AD47', fontColor: 'ffffff', bold: true, horizontalAlignment: 'center', bottomBorder: true, bottomBorderColor: 'EAEAEA' });
|
|
@@ -118,21 +118,21 @@ const XlsxPopulate = require('xlsx-populate');
|
|
|
columnDatas = [columns.map(function(c) {
|
|
columnDatas = [columns.map(function(c) {
|
|
|
return c.name;
|
|
return c.name;
|
|
|
})];
|
|
})];
|
|
|
- r = sheet.range(cell + ":" + new Cell(cell).addCol(clen - 1));
|
|
|
|
|
|
|
+ r = sheet.range(cell + ":" + new Cell(cell).addCol(clen - 2));
|
|
|
r.value(columnDatas);
|
|
r.value(columnDatas);
|
|
|
sheet_columns = r.cells()[0].map(function(c) {
|
|
sheet_columns = r.cells()[0].map(function(c) {
|
|
|
return c.column();
|
|
return c.column();
|
|
|
});
|
|
});
|
|
|
- columns.forEach(function(c, i) {
|
|
|
|
|
|
|
+ for(i = 0; i < columns.length; i++) {
|
|
|
if(sheet_columns[i]) {
|
|
if(sheet_columns[i]) {
|
|
|
- sheet_columns[i].width(c.width);
|
|
|
|
|
|
|
+ sheet_columns[i].width(columns[i].width);
|
|
|
}
|
|
}
|
|
|
- });
|
|
|
|
|
|
|
+ }
|
|
|
r.style({ fill: '70AD47', fontColor: 'ffffff', bold: true, horizontalAlignment: 'center', rightBorder: true, rightBorderColor: 'EAEAEA' });
|
|
r.style({ fill: '70AD47', fontColor: 'ffffff', bold: true, horizontalAlignment: 'center', rightBorder: true, rightBorderColor: 'EAEAEA' });
|
|
|
cell.addRow(1);
|
|
cell.addRow(1);
|
|
|
}
|
|
}
|
|
|
if(rows.length > 0) {
|
|
if(rows.length > 0) {
|
|
|
- r = sheet.range(cell + ":" + new Cell(cell).addRow(rows.length - 1).addCol(clen - 1));
|
|
|
|
|
|
|
+ r = sheet.range(cell + ":" + new Cell(cell).addRow(rows.length - 1).addCol(clen - 2));
|
|
|
r.value(rows);
|
|
r.value(rows);
|
|
|
r.style('fill', function(cell, ri, ci, range) {
|
|
r.style('fill', function(cell, ri, ci, range) {
|
|
|
return (ri&1) === 0 ? 'C6E0B4' : 'A9D08E';
|
|
return (ri&1) === 0 ? 'C6E0B4' : 'A9D08E';
|