8/19 月报
This commit is contained in:
@@ -75,34 +75,36 @@ export function exportToExcel(data: any[], columns: ColumnConfig[], filename: st
|
||||
for (let R = range.s.r; R <= range.e.r; ++R) {
|
||||
for (let C = range.s.c; C <= range.e.c; ++C) {
|
||||
const cellAddress = XLSX.utils.encode_cell({ r: R, c: C });
|
||||
if (worksheet[cellAddress]) {
|
||||
const isHeader = R < headerRows;
|
||||
worksheet[cellAddress].s = {
|
||||
fill: isHeader
|
||||
? {
|
||||
fgColor: { rgb: 'bec4cb' },
|
||||
patternType: 'solid'
|
||||
}
|
||||
: undefined,
|
||||
font: isHeader
|
||||
? {
|
||||
color: { rgb: 'FFFFFF' },
|
||||
bold: true,
|
||||
sz: 11
|
||||
}
|
||||
: undefined,
|
||||
border: {
|
||||
top: { style: 'thin', color: { rgb: '000000' } },
|
||||
bottom: { style: 'thin', color: { rgb: '000000' } },
|
||||
left: { style: 'thin', color: { rgb: '000000' } },
|
||||
right: { style: 'thin', color: { rgb: '000000' } }
|
||||
},
|
||||
alignment: {
|
||||
horizontal: 'center',
|
||||
vertical: 'center'
|
||||
}
|
||||
};
|
||||
// ✅ 确保单元格存在(即使没有内容也要创建,以便设置边框)
|
||||
if (!worksheet[cellAddress]) {
|
||||
worksheet[cellAddress] = { t: 's', v: '' };
|
||||
}
|
||||
const isHeader = R < headerRows;
|
||||
worksheet[cellAddress].s = {
|
||||
fill: isHeader
|
||||
? {
|
||||
fgColor: { rgb: 'bec4cb' },
|
||||
patternType: 'solid'
|
||||
}
|
||||
: undefined,
|
||||
font: isHeader
|
||||
? {
|
||||
color: { rgb: 'FFFFFF' },
|
||||
bold: true,
|
||||
sz: 11
|
||||
}
|
||||
: undefined,
|
||||
border: {
|
||||
top: { style: 'thin', color: { rgb: '000000' } },
|
||||
bottom: { style: 'thin', color: { rgb: '000000' } },
|
||||
left: { style: 'thin', color: { rgb: '000000' } },
|
||||
right: { style: 'thin', color: { rgb: '000000' } }
|
||||
},
|
||||
alignment: {
|
||||
horizontal: 'center',
|
||||
vertical: 'center'
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -143,6 +145,9 @@ export function exportToExcel(data: any[], columns: ColumnConfig[], filename: st
|
||||
|
||||
/**
|
||||
* 根据 spanMethod 回调计算需要合并的单元格范围
|
||||
* @param data
|
||||
* @param columns
|
||||
* @param spanMethod
|
||||
* @param headerRows 表头行数(数据行需要偏移)
|
||||
*/
|
||||
function calculateMergesBySpanMethod(data: any[], columns: ColumnConfig[], spanMethod: SpanMethodCallback, headerRows: number = 1): XLSX.Range[] {
|
||||
|
||||
Reference in New Issue
Block a user