gpt4 book ai didi

angular - 将 Excel 工作表中的数据导出到标题行,背景颜色为

转载 作者:行者123 更新时间:2023-12-02 14:52:15 24 4
gpt4 key购买 nike

我想以 Excel 格式导出数据,并将背景添加到标题行。

我已经使用 Angular2Csv 导出文件,但我无法向标题添加背景颜色。

let options = {
fieldSeparator: ',',
quoteStrings: '"',
decimalseparator: '.',
showLabels: true,
title: 'Doctors Report',
showTitle: true,
headers: ['Fullname','Email','Phone No','],
};

new Angular2Csv(localArray, 'Title', options);

我想要以 excel/csv 格式导出带有标题背景的数组。

最佳答案

CSV 是逗号分隔值,不能采用任何格式。

如果您想将数据导出到具有填充行背景的 Excel 工作表,请使用 https://github.com/SheetJS/js-xlsx/ 。本期有关于如何使用背景颜色的示例:

https://github.com/SheetJS/js-xlsx/issues/906

const COLORS = {
'good': { patternType : 'solid', bgColor : { rgb: 'C6EFCE' }, fgColor : { rgb: 'C6EFCE' }, fontColor : { rgb :'006100'} },
if (headers[C].style) {
if (headers[C].style.color) {
headers[C].style.fill = COLORS[headers[C].style.color];
if (headers[C].style.font) {
headers[C].style.font.color = COLORS[headers[C].style.color].fontColor;
}
}
if (headers[C].style.repeat) {
defaultStyle = headers[C].style;
}
if (defaultStyle) {
ws[address].s = defaultStyle;
}else{
ws[address].s = headers[C].style
}
}else{
ws[address].s = defaultStyle;
}

关于angular - 将 Excel 工作表中的数据导出到标题行,背景颜色为,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57692906/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com