简体   繁体   English

MS Reporting服务-如何传递单元格颜色

[英]MS Reporting services - How to pass cell color

I am trying to create a report that has some data values. 我正在尝试创建具有某些数据值的报告。 Each data value can be of a 'good' or 'bad' quality. 每个数据值的质量可以为“好”或“差”。 I would like to pass a value color through the dataset using a custom C# data provider object. 我想使用自定义C#数据提供程序对象通过数据集传递值颜色。 Once in the report designer, I can use ' Fields!MyColumn.Value ' and it works fine. 进入报表设计器后,我可以使用“ Fields!MyColumn.Value ”,它可以正常工作。 There is also an option to type ' Fields!MyColumn.Color ', but I don't know how to initialize it. 还有一个键入' Fields!MyColumn.Color '的选项,但是我不知道如何初始化它。 Please help. 请帮忙。

This is a code fragment I use to load some data to the report: 这是一个代码片段,用于将一些数据加载到报告中:

IDataReader dataReader = command.ExecuteReader();
  dataset.Tables["dtTable"].Load(dataReader);
  dataReader.Close();

  //provide local report information to viewer
  reportViewer.LocalReport.ReportEmbeddedResource =
       "Client.Reports.Reports.Sample.rdlc";

  //prepare report data sources
  ReportDataSource dsTable = new ReportDataSource();
  dsTable.Name = "dtTableData";
  dsTable.Value = dataset.Tables["dtTable"];
  reportViewer.LocalReport.DataSources.Add(dsTable);

I am not super familiar with the situation but it seems that if it takes a string you should be able to pass anything that the Color field in the report usually takes. 我对这种情况不是很熟悉,但是似乎如果使用字符串,则应该能够传递报表中“颜色”字段通常采用的任何内容。 Any string like "#ffffff" or "white" or an expression like '=IIF(Fields!MyColumn.Value = 1, "blue", "red")'. 任何字符串,例如“ #ffffff”或“ white”或类似“ = IIF(Fields!MyColumn.Value = 1,“ blue”,“ red”))的表达式。 It if requires an integer, then you should set it according to http://msdn.microsoft.com/en-us/library/ms145991.aspx 如果需要整数,则应根据http://msdn.microsoft.com/zh-cn/library/ms145991.aspx进行设置

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

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