reporting-services - 报告服务部分彩色单元格

标签 reporting-services ssrs-2008

如何在报告服务表或矩阵中创建部分着色的单元格?例如:我的值为 45,我只想用红色填充 45% 的单元格,而其他 55% 的单元格保持白色?

最佳答案

我认为可行的唯一方法是为您要显示的每个百分比带设置一个充满 x% 红色的背景图像。 然后,您可以设置一个表达式,根据特定字段的值用正确的图像填充背景。

这不是最好的解决方案,因为您将需要 20 张图像才能获得 5% 的波段。

另一种选择是编写一个 webservice/asp.net 页面,该页面将根据查询字符串以正确的比例生成图像。然后就可以给aspx页面设置背景图片了。 This article是如何通过 asp.net 动态创建图像的示例

测试了以下代码,它可以很好地生成单元格图表。

 protected void Page_Load(object sender, EventArgs e)
    {
        int percent = 0;
        int height = 20;

        if (Request.QueryString.AllKeys.Contains("percent"))
        {
            int.TryParse(Request.QueryString["percent"], out percent);
        }

        if (Request.QueryString.AllKeys.Contains("height"))
        {
            int.TryParse(Request.QueryString["height"], out height);
        }

        Bitmap respBitmap = new Bitmap(100, height, PixelFormat.Format32bppRgb);
        Graphics graphics = Graphics.FromImage(respBitmap);
        Brush brsh = new SolidBrush(Color.White);
        graphics.FillRectangle(brsh, new Rectangle(0, 0, respBitmap.Width, respBitmap.Height));

        brsh = new SolidBrush(Color.Red);
        graphics.FillRectangle(brsh, new Rectangle(0, 0, respBitmap.Width * percent / 100, respBitmap.Height));

        Response.ContentType = "image/jpeg";
        Response.Charset = "";
        respBitmap.Save(Response.OutputStream, ImageFormat.Jpeg);

    }

转到所需的文本框,将 BackGroundImage 源更改为外部并将值更改为表达式。 使用类似于

的表达式
= "http://mysite/chartimage.aspx?percentage=" & Fields!MyField.Value

关于reporting-services - 报告服务部分彩色单元格,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4317637/

相关文章:

ssrs-2008 - 通过数据值更改 SSRS 报告中的行颜色

postgresql - 在 PostgreSQL 中获取前 1 个月或前 2 个月的所有日期

php - 如何在 php 中打开 ssrs rdl 文件

reporting-services - 去除 SSRS 表达式中的小数点而不进行舍入

reporting-services - 使用列和行分组在 Tablix 中进行交互式排序

reporting-services - 在 SSRS 表达式中为空

java - 通过 Internet 进行邮件合并

c# - 通过 Management Studio 和 C# 应用程序访问 Reporting Services

reporting-services - 根据特定参数值显示或隐藏 SSRS 列

reporting-services - SSRS 2008 NULL 参数