在Excel中将HEX转换为RGB [英] Convert HEX to RGB in Excel
问题描述
我有一个列"HEX"和三个列"R","G"和"B".
I have a column "HEX" and three columns "R", "G", and "B".
如何将十六进制转换为RGB,例如ff0000
到R=255
,G=0
和B=0
?
How can I convert a HEX to RGB, e.g. ff0000
to R=255
, G=0
, and B=0
?
我知道前2个字符ff
属于"R",后2个00
属于"G",最后2个00
属于"B".因此,我将不得不在=RIGHT(LEFT(A1, 4), 2)
和=RIGHT(A1, 2)
上使用=LEFT(A1, 2)
.
I know that the first 2 characters ff
belongs to "R", the next 2 00
belongs to "G", and the final 2 00
belongs to "B". So I will have to use =LEFT(A1, 2)
for "R", =RIGHT(LEFT(A1, 4), 2)
, and =RIGHT(A1, 2)
for the last.
但是如何将ff
转换为255
和00
转换为0
,等等?我想我需要做一些事情来从十六进制(以16为底)解析为十进制(以10为底)?
But how can I convert ff
to 255
and 00
to 0
, etc.? I guess I will have to do something to parse from hexadecimal (base 16) to decimal (base 10)?
我想在没有VBA的情况下这样做.
I would like to do it without VBA.
推荐答案
您可以使用HEX2DEC()
函数将十六进制转换为十进制.例如:
You can convert from hex to decimal using the HEX2DEC()
function. For instance:
=HEX2DEC(A1)
单元格A1
中包含字符串FF
的地方,将返回255
.
Where cell A1
contains the string FF
, this will return 255
.
这篇关于在Excel中将HEX转换为RGB的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!