简体   繁体   English

如何使用HTML更改Crystal Reports中的字段背景颜色?

[英]How to change the field background color in Crystal Reports using HTML?

I have a cross-tab in the report. 我在报告中有一个交叉表。 I need to change background color of the summary field based on the database field HEX value. 我需要根据数据库字段的十六进制值更改摘要字段的背景颜色。 For this I'm interpreting field as HTML. 为此,我将字段解释为HTML。 So I created the formula fields and trying to use HTML tags to format it. 因此,我创建了公式字段,并尝试使用HTML标签对其进行格式设置。 I can change the font color OK, like this: 我可以更改字体颜色,如下所示:

在此处输入图片说明

But I cannot figure out how to change the background color. 但是我不知道如何更改背景颜色。 I have a database field for this - {Report_SELECT_TagLayouts.BackgroundColorHex}, but even if I just use regular HEX values it doesn't work. 我为此有一个数据库字段-{Report_SELECT_TagLayouts.BackgroundColorHex},但是即使我只是使用常规的十六进制值也无法使用。 I've tried different tags - div, span etc. - no luck. 我尝试了不同的标签-div,span等-没运气。

I understand that Crystal reports support only limited number of HTML tags, but whatever I try is not working. 我了解Crystal报表仅支持有限数量的HTML标记,但是我尝试执行的任何操作均不起作用。 Font color is fine. 字体颜色很好。

I would appreciate your suggestions. 非常感谢您的建议。

Unfortunately, you will need to convert your hex to rgb. 不幸的是,您将需要将十六进制转换为rgb。
I would then go to then go to the border tab, click on the background X-2 in the Color box. 然后,我要转到“边界”选项卡,在“颜色”框中单击背景X-2。 You would then place the your criteria (if x then color(r,g,b) else crNoColor You will probably need to create a variable formula for the rgb conversion ig 然后,您将放置您的条件(如果x然后是color(r,g,b),则为crNoColor,您可能需要为rgb转换ig创建一个变量公式

local numberVar R;
local numberVar B;
local numberVar G;
local stringVar convert;
convert =: R & "," & "," & B & "," & G;

if x then color(convert) else crNoColor

good news though is that someone has already done conversion math. 好消息是有人已经完成了转换数学。 http://www.rapidtables.com/convert/color/hex-to-rgb.htm http://www.rapidtables.com/convert/color/hex-to-rgb.htm

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM