@chenchaolong/plugin-trade-compliance-workbench 1.0.34 → 1.0.35

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -76,8 +76,8 @@ function cellStyle(cell) {
76
76
  if (font.strike) style.st = { s: 1 }
77
77
  const fontColor = color(font.color)
78
78
  if (fontColor) style.cl = { rgb: fontColor }
79
- const fillColor = color(fill.fgColor || fill.bgColor)
80
- if (fillColor) style.bg = { rgb: fillColor }
79
+ const fillColorValue = fillColor(fill)
80
+ if (fillColorValue) style.bg = { rgb: fillColorValue }
81
81
  const horizontal = horizontalAlign(alignment.horizontal)
82
82
  if (horizontal) style.ht = horizontal
83
83
  const vertical = verticalAlign(alignment.vertical)
@@ -90,7 +90,17 @@ function cellStyle(cell) {
90
90
 
91
91
  function color(value) {
92
92
  const argb = typeof value?.argb === 'string' ? value.argb : ''
93
- return argb.length === 8 ? argb.slice(2) : argb || undefined
93
+ const raw = argb.length === 8 ? argb.substring(2) : argb
94
+ const rgb = raw.trim().replace(/^#/, '').toUpperCase()
95
+ if (!/^[0-9A-F]{6}$/.test(rgb)) return undefined
96
+ return `#${rgb}`
97
+ }
98
+
99
+ function fillColor(fill) {
100
+ if (!fill || fill.type !== 'pattern' || fill.pattern === 'none') return undefined
101
+ const normalized = color(fill.fgColor || fill.bgColor)
102
+ if (normalized === '#FFFFFF') return undefined
103
+ return normalized
94
104
  }
95
105
 
96
106
  function horizontalAlign(value) {
@@ -106,7 +116,7 @@ function borderStyle(border) {
106
116
  const map = { top: 't', right: 'r', bottom: 'b', left: 'l' }
107
117
  for (const [excelKey, univerKey] of Object.entries(map)) {
108
118
  const side = border[excelKey]
109
- if (side?.style) result[univerKey] = { s: side.style === 'medium' || side.style === 'thick' ? 2 : 1, cl: { rgb: color(side.color) || '000000' } }
119
+ if (side?.style) result[univerKey] = { s: side.style === 'medium' || side.style === 'thick' ? 2 : 1, cl: { rgb: color(side.color) || '#000000' } }
110
120
  }
111
121
  return Object.keys(result).length ? result : undefined
112
122
  }