表达式根据另一个字段更改SSRS中值的字符串中的特定值文本颜色(Expression to change specific value text color in string of values i

编程入门 行业动态 更新时间:2024-10-27 22:32:24
表达式根据另一个字段更改SSRS中值的字符串中的特定值文本颜色(Expression to change specific value text color in string of values in SSRS based on another field)

我的SSRS报告中有一个字段,其中包含用逗号分隔的一串数字(来自SQL中的coalesce select)。 它看起来像12,91,160,171,223。我想在字段中仅更改一个特定值(例如160)的文本颜色,如果该值也在报告的另一个字段中。

我已经将它用于字段属性的Font的表达式。

=iif(Fields!Store_Number.Value.ToString().Contains (Fields!DMHomeStore.Value)= True,"Red","Black")

这会更改整个字段的文本颜色,而不仅仅是字符串中的ONE值。

基本上,如果DMHomeStore = 160,并且Store_Number在其字符串中有160,那么在Store_Number字符串中只使用160 Red。

I have a field in my SSRS report, that contains a string of numbers delimited with commas (from a coalesce select in SQL). It looks like 12, 91, 160, 171, 223. I would like to change the text color of only ONE specific value (160 for example) in the field, IF the value is also in another field of the report.

I already have this for an expression for the Font of the field properties.

=iif(Fields!Store_Number.Value.ToString().Contains (Fields!DMHomeStore.Value)= True,"Red","Black")

This changes the text color of the entire field, not just that ONE value in the string.

Basically, if DMHomeStore = 160, and Store_Number has 160 in it's string, then make only 160 Red in the Store_Number string.

最满意答案

这当然可以做到并且不难做到。

从空表格单元格开始。 双击单元格 - >右键单击 - >创建占位符 在常规选项卡上,值 - >选择将包含数字字符串的字段 在同一个常规选项卡上,选择“HTML,将HTML标记解释为样式 单击确定

这是第一步。 现在,我们需要做的就是设置一个表达式,它将找到有问题的字符串,然后用HTML代码替换它以使其变为红色。

右键单击单元格 - >选择表达式 输入以下表达式: =Replace(Fields!Store_Number.Value.ToString(),Fields!DMHomeStore.Value," `<span style='color:red'>` " & Fields!DMHomeStore.Value & "`</span>`")

运行您的报告,只有相关字符串为红色,单元格中的所有其他文本都为黑色。 如果找不到相关字符串,则所有其他文本将为黑色。

This can certainly be done and isn't difficult to do.

Start with an empty table cell. Double click on the cell -> Right-Click -> Create Placeholder On the General tab, Value -> select the field that will contain the string of numbers On the same General tab, select "HTML, interpret HTML tags as styles Click OK

That's the first step. Now, all we need to do is set up an expression that will find the string in question and then replace it with HTML code to make it red.

Right-click on the cell -> Select Expression Enter the following expression: =Replace(Fields!Store_Number.Value.ToString(),Fields!DMHomeStore.Value," `<span style='color:red'>` " & Fields!DMHomeStore.Value & "`</span>`")

Run your report and only the string in question will be red and all other text in the cell will be black. If the string in question isn't found then all other text will be black.

更多推荐

本文发布于:2023-08-07 19:03:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1465660.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:中值   表达式   字段   字符串   文本

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!