【发布时间】:2018-04-10 07:14:20
【问题描述】:
我正在使用 openxml(vb.net) 更改 docx 中的字体颜色。如何将静态颜色更改为 RGB 颜色/自定义颜色?下面是我的代码,但不起作用:
Function AddColor(ByVal isFontColor As Boolean, ByVal text As String) As Run
Dim runs = New Run()
If isFontColor = True Then
Dim props = New RunProperties()
Dim fontColor = New Color With {.Val = CType(RGB(255, 200, 50), StringValue)}
props.AppendChild(fontcolor)
runs.Append(props)
End If
runs.Append(New Text(text))
Return runs
End Function
原静态色码:
Function AddColor(ByVal isFontColor As Boolean, ByVal text As String) As Run
Dim runs = New Run()
If isFontColor = True Then
Dim props = New RunProperties()
Dim fontColor = New Color With
{.Val = "red"} 'Dark red
props.AppendChild(fontColor)
runs.Append(props)
'Set font color to default color
Else isFontColor = False
Dim props = New RunProperties()
Dim fontColor = New Color With
{.Val = “default"} 'Default Color
props.AppendChild(fontColor)
runs.Append(props)
End If
runs.Append(New Text(text))
Return runs
End Function
【问题讨论】:
-
嗨,Eric,实际上没有工作的是什么?您可以发布您如何使用该功能吗?干杯
-
其实我的意思是我想添加颜色使用RGB格式,而不是把“紫色”然后得到紫色,我想用rgb添加颜色
标签: vb.net openxml-sdk