如何根据数据集中的值在报告服务中为标签着色?
我有一个 SQL Server 2005 Express Reporting Server,我正在尝试更新报表以根据存储在数据库中的值显示彩色标签。
我当前将颜色存储为 aRGB 值,但如果需要,我可以更改它。
我看过关于如何在颜色属性中使用表达式的帖子,但我无法在那里嵌入 C#。
谢谢!
I have an SQL Server 2005 Express Reporting Server and I'm trying update a report to show a coloured label based on a value stored in the database.
I currently store the colour as an aRGB value, but I can change this if required.
I've seen posts on how to use expression in the color property, but I can't embed c# there.
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
SSRS使用VB.NET,而不是C#,大多数地方都会接受代码,它以“=”为前缀,让解析器知道它是代码。我不知道你想在哪里设置标签(在表格中,在浮动文本框中等),但它很可能是可行的。
SSRS uses VB.NET, not C#, and most places will accept code, it is prefixed with a '=' to let the parser know that it is code. I don't know exactly where you are trying to set the label (in a table, in a floating textbox, etc), but it is very likely that it is doable.
经过一番挖掘,我发现你必须使用 VB 代码。
这是步骤。
将此自定义代码添加到报告属性 ->代码选项卡
公共函数 GetMyColour(myColour 作为整数)作为字符串
Dim colorObj As System.Drawing.Color = System.Drawing.Color.FromArgb(myColour)
return String.Format("#{0:X2}{1:X2}{2:X2}", colorObj.R, colorObj.G, colorObj.B)
End Function
在要设置颜色的报表对象上设置颜色属性表达式
=Code.GetMyColour(First(Fields!RecipeColour.Value, "StockControl"))
After some digging I found out that u have to use VB code.
Here's the steps.
Add this custom code to the report properties -> code tab
Public Function GetMyColour(myColour as integer) as string
Dim colorObj As System.Drawing.Color = System.Drawing.Color.FromArgb(myColour)
return String.Format("#{0:X2}{1:X2}{2:X2}", colorObj.R, colorObj.G, colorObj.B)
End Function
Set the color property expression on the report object you want set the color of to this
=Code.GetMyColour(First(Fields!RecipeColour.Value, "StockControl"))