3
如何在報告服務表格或矩陣中創建偏色的單元格?例如:我的價值是45我想要只填充45%的紅色,其他55%保持白色?部分着色的報告服務單元格
如何在報告服務表格或矩陣中創建偏色的單元格?例如:我的價值是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
這樣的表達方式這是可能的某種其他方式嗎? – buda 2010-12-01 15:09:32