如何在EXCEL单元格中设置字体颜色? [英] How do you set the font color in an EXCEL cell?

查看:586
本文介绍了如何在EXCEL单元格中设置字体颜色?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

其中xlWs是Excel.Worksheet,xlRG是Excel.Range

xlRG = xlWS.Cells(row,7)

xlRG.Font.Bold = True

xlRG.Font.Color = 255


在VB6中你可以简单地说xlRG.Font.Color = vbRed但是在.net那里

不是常量vbRed,Color.Red给出的格式无效。是否有一套

枚举颜色可以在这里使用?

Where xlWs is an Excel.Worksheet and xlRG is an Excel.Range
xlRG = xlWS.Cells(row, 7)
xlRG.Font.Bold = True
xlRG.Font.Color = 255

In VB6 you could just simply say xlRG.Font.Color = vbRed but in .net there
is no constant vbRed and Color.Red gives an invalid format. Is there a set of
enumerations of colors that will work here?

推荐答案

Darrell,


我怀疑它是否与Interop想要的颜色相同,但是VBNet中的颜色很容易用Color.Red获得(这是一个枚举所以a一堆

的颜色显示)


我希望这有帮助吗?


Cor

" Darrell Wesley" < Da *********** @ discussion.microsoft.com>
Darrell,

I am in doubt if it is the same colourcode as the Interop wants, however a
colour in VBNet is just easy to get with Color.Red (it is a enum so a bunch
of colours is showed)

I hope this helps?

Cor
"Darrell Wesley" <Da***********@discussions.microsoft.com>
其中xlWs是Excel.Worksheet,xlRG是Excel.Range

xlRG = xlWS.Cells(row,7)
xlRG.Font.Bold = True
xlRG.Font.Color = 255

在VB6中你可以简单地说xlRG。 Font.Color = vbRed但在.net中没有常量vbRed和Color.Red给出无效格式。是否有一套
的颜色枚举可以在这里使用?
Where xlWs is an Excel.Worksheet and xlRG is an Excel.Range
xlRG = xlWS.Cells(row, 7)
xlRG.Font.Bold = True
xlRG.Font.Color = 255

In VB6 you could just simply say xlRG.Font.Color = vbRed but in .net there
is no constant vbRed and Color.Red gives an invalid format. Is there a set
of
enumerations of colors that will work here?



你好
xlRG = xlWS.Cells(row,7)
xlRG.Font.Bold = True
xlRG.Font.Color = 255
xlRG = xlWS.Cells(row, 7)
xlRG.Font.Bold = True
xlRG.Font.Color = 255




Excel-Workbook:

xlWB.Colors(1)= RGB(255,255,255)

xlWB.Colors(2)= RGB(225,225,225)

xlWB.Colors(3)= RGB(200,200,200)

Excel-工作表

xlWS.Range(" A1:A30")。Interior.ColorIndex = 1

xlWS.Range(" B1:B30")。Interior.ColorIndex = 2

xlWS.Range(" C1:C30")。Interior.ColorIndex = 3


这对我来说很好用


Frank



Excel-Workbook:
xlWB.Colors(1) = RGB(255,255,255)
xlWB.Colors(2) = RGB(225,225,225)
xlWB.Colors(3) = RGB(200,200,200)

Excel-Worksheet
xlWS.Range("A1:A30").Interior.ColorIndex = 1
xlWS.Range("B1:B30").Interior.ColorIndex = 2
xlWS.Range("C1:C30").Interior.ColorIndex = 3

This works fine for me

Frank


Darrell Wesley <沓*********** @ discussions.microsoft.com>在消息新闻中写道:< 33 ********************************** @ microso ft.com> .. 。
"Darrell Wesley" <Da***********@discussions.microsoft.com> wrote in message news:<33**********************************@microso ft.com>...
其中xlWs是Excel.Worksheet,xlRG是Excel.Range

xlRG = xlWS.Cells(row,7)
xlRG.Font.Bold = True
xlRG.Font.Color = 255

在VB6中你可以简单地说xlRG.Font.Color = vbRed但是在.net那里
没有常数vbRed和颜色.Red提供的格式无效。是否有一套颜色的枚举可以在这里使用?
Where xlWs is an Excel.Worksheet and xlRG is an Excel.Range
xlRG = xlWS.Cells(row, 7)
xlRG.Font.Bold = True
xlRG.Font.Color = 255

In VB6 you could just simply say xlRG.Font.Color = vbRed but in .net there
is no constant vbRed and Color.Red gives an invalid format. Is there a set of
enumerations of colors that will work here?




嗨Darrell,


什么是确切的消息?可能是铸造问题。

TTH,

Adel A. Al-saleh



Hi Darrell,

What was the exact message? May it is a casting problem.
TTH,
Adel A. Al-saleh


这篇关于如何在EXCEL单元格中设置字体颜色?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆