|
@@ -95,6 +95,8 @@ var setStyleAndValue = function(cellArr, worksheet) {
|
|
row.every(function(cell, columnid) {
|
|
row.every(function(cell, columnid) {
|
|
if (!cell) return true;
|
|
if (!cell) return true;
|
|
let fill = fillConvert(cell.bg);
|
|
let fill = fillConvert(cell.bg);
|
|
|
|
+ if (fill?.fgColor?.argb && fill?.fgColor?.argb.includes('rgb'))
|
|
|
|
+ fill.fgColor.argb = rgbToHex(fill.fgColor.argb);
|
|
|
|
|
|
let font = fontConvert(cell.ff, cell.fc, cell.bl, cell.it, cell.fs, cell.cl, cell.ul);
|
|
let font = fontConvert(cell.ff, cell.fc, cell.bl, cell.it, cell.fs, cell.cl, cell.ul);
|
|
let alignment = alignmentConvert(cell.vt, cell.ht, cell.tb, cell.tr);
|
|
let alignment = alignmentConvert(cell.vt, cell.ht, cell.tb, cell.tr);
|
|
@@ -322,3 +324,32 @@ function createCellPos(n) {
|
|
}
|
|
}
|
|
return s;
|
|
return s;
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+function rgbToHex(rgbString) {
|
|
|
|
+ // var rgbString = "rgb(255, 255, 255)";
|
|
|
|
+ var hexColor = 'FFFFFF';
|
|
|
|
+
|
|
|
|
+ // 使用正则表达式匹配出数字部分
|
|
|
|
+ var match = rgbString?.match(/\d+/g);
|
|
|
|
+
|
|
|
|
+ if (match) {
|
|
|
|
+ var r = parseInt(match[0]); // 第一个匹配项是红色分量
|
|
|
|
+ var g = parseInt(match[1]); // 第二个匹配项是绿色分量
|
|
|
|
+ var b = parseInt(match[2]); // 第三个匹配项是蓝色分量
|
|
|
|
+
|
|
|
|
+ console.log('Red:', r);
|
|
|
|
+ console.log('Green:', g);
|
|
|
|
+ console.log('Blue:', b);
|
|
|
|
+ // 将每个RGB分量转换为十六进制,并确保至少两位
|
|
|
|
+ var redHex = r.toString(16).padStart(2, '0');
|
|
|
|
+ var greenHex = g.toString(16).padStart(2, '0');
|
|
|
|
+ var blueHex = b.toString(16).padStart(2, '0');
|
|
|
|
+
|
|
|
|
+ // 将三个分量的十六进制值连接起来
|
|
|
|
+ hexColor = redHex + greenHex + blueHex;
|
|
|
|
+
|
|
|
|
+ // 转换为大写字母形式
|
|
|
|
+ hexColor = hexColor.toUpperCase();
|
|
|
|
+ }
|
|
|
|
+ return hexColor;
|
|
|
|
+}
|