使用CMYK单元格值在Excel中着色单元格

我正在寻找一种可能使用VBA的方式,通过查看相同logging中的指定字段来应用单元格的填充值。 这将是一个示例制表符分隔的Excel工作表:

BEGIN_DATA_FORMAT SampleID SAMPLE_NAME CMYK_C CMYK_M CMYK_Y CMYK_K LAB_L LAB_A LAB_B BEGIN_DATA 1 1 100 0 0 60 34.16 -19.52 -27.46 2 2 100 100 0 60 22.02 6.27 -23.25 3 3 100 0 0 0 54.56 -31.12 -45.29 END_DATA 

字段3-6分别包含CMYK的值。 我想通过parsing组合的CMYK值的每个logging作为起点来应用单元格背景填充字段1。

除非在Excel / Windows颜色select器中有后门方法来设置CMYK值,否则最初可能需要转换为RGB或HSL。

这会给你在你的数据CYMK RGB:

 Function CYMK2RGB(c As Integer, y As Integer, m As Integer, k As Integer) As Long Dim R As Integer Dim G As Integer Dim B As Integer Dim colors As Integer colors = 255 * (100 - k) / 100 R = colors * (100 - c) / 100 G = colors * (100 - m) / 100 B = colors * (100 - y) / 100 CYMK2RGB = RGB(R, G, B) End Function 

使用range("A1").Interior.Color=cymk2rgb(...)将设置颜色 – 注意它不会完全匹配,因为CYMK是减法的,而RGB是加法的。 这个网站: http : //www.printernational.org/rgb-versus-cmyk.php有比较两个更多的细节。