ssrs行高

Setting alternate row colors in SSRS (SQL Server Reporting Services) is an important visualization configuration for end-users so that they can easily view their reports. However, setting alternate colors in SSRS is not a click of a button configuration like in the Microsoft Excel.

在SSRS(SQL Server Reporting Services)中设置备用行颜色是最终用户的重要可视化配置,以便他们可以轻松查看其报告。 但是,在SSRS中设置替代颜色并不是像Microsoft Excel中那样单击按钮配置。

The following screenshot shows the output in Microsoft Excel when the Alternate row color is set for a table.

以下屏幕快照显示了为表设置“备用行”颜色时Microsoft Excel的输出。

However, in SSRS this is not straight forward as in Microsoft Excel shown in the above screenshot.

但是,在SSRS中,这并不像上面的屏幕快照中所示的Microsoft Excel那样直接。

Let us configure a report in SSRS.

让我们在SSRS中配置报告。

SSRS样本报告 (SSRS Sample Report)

Following is the SSRS project solution.

以下是SSRS项目解决方案。

First, the data source is created for the AdventureWorks sample database in any SQL Server instance. After the data source creation, the next step is to create a data set with the following t-SQL code.

首先,在任何SQL Server实例中为AdventureWorks示例数据库创建数据源。 创建数据源之后,下一步就是使用以下t-SQL代码创建数据集。

SELECT SO.SalesOrderID,SO.RevisionNumber,SO.OrderDate,P.NAME AS ProductName,SOD.OrderQty,SOD.UnitPrice,SOD.LineTotal
FROM Sales.SalesOrderDetail AS SOD
INNER JOIN Sales.SalesOrderHeader AS SO ON SOD.SalesOrderID = SO.SalesOrderID
INNER JOIN Production.Product AS P ON SOD.ProductID = P.ProductID
WHERE SOD.SalesOrderID IN (43660,43663,43666,43672,43682,43685)
ORDER BY SO.SalesOrderID

Please note that only six orders are used for demonstration purposes. Also, the data set is sorted by the order by OrderID for the demonstration purposes.

请注意,仅六个订单用于演示目的。 同样,出于演示目的,数据集按OrderID和OrderID排序。

Next is to create a table in the SSRS report and link with the data set and you will see the following report.

接下来是在SSRS报告中创建一个表并与数据集链接,您将看到以下报告。

No major formatting was done to the report except for the rounding the Line total to the two decimal points.

除了将“行总计”四舍五入到小数点后两位以外,没有对报告进行任何主要格式设置。

表的SSRS中的备用行颜色 (Alternate Row Colors in SSRS for Table)

The next task is to set alternate row colors in SSRS in the above SSRS Report.

下一个任务是在上述SSRS报告中的SSRS中设置备用行颜色。

Right-click the data row as shown in the below screenshot, click F4 or properties window in the View menu.

右键单击数据行,如下面的屏幕快照所示,在视图菜单中单击F4或属性窗口。

When selecting this, you will see the BackgroundColor option. By default, it is No Color, which means that there is no color for the background and use can select any colors. However, those options will provide a report with the same colors for all rows, not for alternate row colors in SSRS Report as required.

选择此项时,您将看到BackgroundColor选项。 默认情况下,它是No Color ,这意味着背景没有颜色,用户可以选择任何颜色。 但是,这些选项将为所有行提供具有相同颜色的报告,而不是根据需要为SSRS报告中的替代行颜色提供报告。

You can select the Expression… option in the listed options which will give you a screen when you can enter an expression.

您可以在列出的选项中选择“ 表达式...”选项,当您输入表达式时,将显示一个屏幕。

In the expression, ROWNUMBER function is used. ROWNUMBER will be the row number for the row. The method used in this case is that the odd row numbers are light blue while the even row numbers are blue. Odd rows are found by for the rows which has reminder 1 when the row number is divided by 2 and similarly, the even rows are the rows which will be the reminder 0 when the row number is divided by 2. This entire logic is used with the IIF and ROWNUMBER functions as shown in the above screenshot.

在表达式中,使用了ROWNUMBER函数。 ROWNUMBER将是该行的行号。 在这种情况下使用的方法是奇数行号为浅蓝色,而偶数行号为蓝色。 对于行号除以2时具有提醒1的行,可以找到奇数行,类似地,偶数行是当行号除以2时将成为提醒0的行。 IIF和ROWNUMBER的功能如上面的屏幕截图所示。

Then the SSRS report is shown as following which has alternate row colors.

然后,SSRS报告如下所示,具有备用行颜色。

Now this will be same as what you get in Microsoft Excel.

现在,这将与您在Microsoft Excel中获得的内容相同。

分组时SSRS中的备用行颜色 (Alternate Row Colors in SSRS When Grouping)

In SSRS, typically you add groups to the detail records. For example, in the above report, the Sales Order ID is repeated in the above data set. This means that the report can be grouped by the Sales Order ID and when the grouping is done, the report will be looked like the following screenshot.

在SSRS中,通常将组添加到详细记录。 例如,在以上报告中,在以上数据集中重复了销售订单ID。 这意味着可以按销售订单ID对报告进行分组,完成分组后,该报告将看起来像以下屏幕截图。

You will observe that background color has gone wrong for the grouping rows. This is because an additional row is introduced to the grouping column. To avoid this, the background color of the grouping row should be modified accordingly.

您会发现分组行的背景色出了问题。 这是因为在分组列中引入了另一行。 为避免这种情况,应相应地修改分组行的背景色。

Then the report will look like the following screenshot.

然后该报告将类似于以下屏幕截图。

SSRS矩阵控件中的备用行颜色 (Alternate Row Colors in SSRS Matrix Control)

Matrix is an SSRS control from which you can have dynamic columns and rows. This means that unlike in the previous example of tables, in the matrix control, columns will grow.

Matrix是一个SSRS控件,您可以从中获得动态的列和行。 这意味着与前面的表示例不同,在矩阵控件中,列将增加。

In the following report, order numbers are in the columns while the product names are in the rows. In case you get a new order number that will appear in the next column.

在以下报告中,订单号在列中,而产品名称在行中。 如果您获得一个新的订单号,该号码将出现在下一列中。

Due to this dynamic nature of the report, the previous simple rule will not work for matrix. If you apply the same rule, the alternate color will occur not at the row level but for every value in the matrix.

由于报告具有这种动态性质,因此以前的简单规则不适用于矩阵。 如果您应用相同的规则,则替代色将不会出现在行级别,而是会出现在矩阵中的每个值上。

This means we need a new approach for the reports with matrix control.

这意味着我们需要采用矩阵控制的报告的新方法。

  1. Add a column outside the dynamic columns which are shown in the following screenshot and highlighted column is the newly added column

    在动态列之外添加一列,如以下屏幕截图所示,突出显示的列是新添加的列

  2. Then add an expression to the newly added column as shown in the below screenshot. This column is Textbox10

    Expression is : =IIF(RUNNINGVALUE (Fields!ProductName.Value,CountDistinct,Nothing) Mod 2, “LightBlue”, “Blue”)

    It is similar to the previous expression, but only thing is, RUNNINGVALUE for the grouped column which is the Product Name is used.

    Now you will get the color into the text value as shown in the below screenshot:

    然后将表达式添加到新添加的列,如下面的屏幕快照所示。 此列是Textbox10

    表达式为: = IIF(RUNNINGVALUE(Fields!ProductName.Value,CountDistinct,Nothing)Mod 2,“ LightBlue”,“ Blue”)

    它与先前的表达式相似,但唯一的区别是,使用了分组列(即产品名称)的RUNNINGVALUE。

    现在,您将把颜色变成文本值,如下面的屏幕截图所示:

  3. Next step is to get the background color from the value of the newly added column. Since the color is available the newly added column, that color can be set to the background of the matrix row

    下一步是从新添加的列的值中获取背景色。 由于颜色是新添加的列可用,因此可以将该颜色设置为矩阵行的背景

  4. Next is to hide the newly added column since this column is used only as an internal column to the report. This can be done by setting the Hidden option to True

    下一步是隐藏新添加的列,因为此列仅用作报表的内部列。 可以通过将“ 隐藏”选项设置为“ True”来完成

Finally, the report will look like the following screenshot.

最后,该报告将类似于以下屏幕截图。

In both the modes, a new the column is added, and it will automatically get the necessary background color so that it does not need any additional configurations. Also, instead of the name of the color, you can use the color code which can be taken from the RGB Color Codes Chart

在这两种模式下,都会添加新的列,并且该列将自动获得必要的背景色,因此不需要任何其他配置。 另外,您可以使用可以从RGB颜色代码表中获取的颜色代码来代替颜色名称。

翻译自: https://www.sqlshack.com/alternate-row-colors-in-ssrs/

ssrs行高

ssrs行高_SSRS中的备用行颜色相关推荐

  1. 调整表格的行高_Word表格无法调整行高?尽然是这个原因,90%的人都可能遇到...

    今天,老婆编辑一篇word文档,可是却被其中的表格弄得晕头转向,还给我撒了一把火.哎,难啊! 我得总结一下word表格中的这个异类,免得有更多的同胞们像我一样被"火烤". Word ...

  2. php中调行高代码_单元格行高怎么设置

    单元格行高怎么设置? 如图一张表,全选,全选的快捷键是Ctrl+A.全选之后第一种方法是直接用鼠标放到最前面的竖栏上,放在数据与数据之间交叉的框上,会出现一个+字的符号. 这个时候点击鼠标左键拉动,就 ...

  3. java中的命令行参数_Java中的命令行参数

    java中的命令行参数 Command-line arguments in Java are used to pass arguments to the main program. If you lo ...

  4. java excel行高_Java 设置Excel自适应行高、列宽

    在excel中,可通过设置自适应行高或列宽自动排版,是一种比较常用的快速调整表格整体布局的方法.设置自适应时,可考虑2种情况: 1.固定数据,设置行高.列宽自适应数据(常见的设置自适应方法) 2.固定 ...

  5. html5行高有什么用,css行高line-height的一些深入理解及应用

    1.一些字面意思 "行高"是指两行文字间基线之间的距离.基线是在英文字母中用到的一个概念,我们刚学英语的时使用的那个英语本子每行有四条线,其中底部第二条线就是基线,是a,c,z,x ...

  6. 计算机设置单元格行高,word表格调整(行高、列宽、单元格宽度)方法技巧-行距怎么设置...

    在word中使用表格经常需要针对性调整其行高与列宽,有时侯也需要对某个单元格单独调整宽度(需要注意的是:单元格不能单独调整高度.针对整个表格只有宽度调整.表格高度是通过对每一行的高度来调整.) 表格大 ...

  7. android+设置字体行高,TextView设置行间距、行高,以及字间距

    一. 设置TextView行间距.行高: Android系统中TextView有默认行间距,但是比较窄有的时候需要我们设置每行行间距. TextView为我们提供了相关设置属性android:line ...

  8. android 行高和字号之间关系,行高和字号

    行高:指的是每一行的高度 盒子高:指的是元素的高度 1.文字默认在行高中默认是居中显示的 2.如果盒子中只有一行内容,要让这一行内容居中,只需要设置行高=盒子高度(line-height = 盒子高度 ...

  9. java 接收命令行参数_java中的命令行参数_Java中的命令行参数

    java中的命令行参数 Command-line arguments in Java are used to pass arguments to the main program. If you lo ...

最新文章

  1. C语言编程技巧-signal(信号机制)
  2. 解析IBM TSM6.0版本特色功能与技术优势
  3. 【转载自codeproject】Another Look At IDisposable
  4. 先装VS 在装IIS遇到的问题
  5. java int 128 ==_为什么 Java Integer 中“128==128”为false,而”100==100“为true?
  6. oracle 052 题库变了,Oracle OCP题库变了,052全新题库收集整理-30
  7. 长按UIWebView上的图片保存到相册
  8. python生成指定年份所有的天,并计算每天属于一年的第几周和周几
  9. Java编程思想笔记目录
  10. python生成的exe反编译
  11. matlab igbt 关断,IGBT关断过程的分析
  12. 三层架构(网络冗余学习)
  13. 恐龙拼图游戏 - 恐龙世界积木拼图游戏
  14. 央视春晚歌手王琪,和戏歌双绝吴广全在长春芝华仕会盟
  15. 内部和外部聚类算法评价指标
  16. 7.5 - 防火墙 7.6 - 安全协议
  17. 使用pdfcrack破解PDF密码(Linux)
  18. 操作系统真象还原第10章:输入输出系统
  19. UE4:打包项目前设置
  20. android 三星闪退,三星手机升级安卓10微信闪退怎么办?(附解决方法)

热门文章

  1. 二维数组最大值首尾相连
  2. 【nodejs】让nodejs像后端mvc框架(asp.net mvc)一样处理请求--请求处理函数装饰器注册篇(5/8)【controller+action】...
  3. java中的与或运算
  4. BZOJ 1019: [SHOI2008]汉诺塔( dp )
  5. (剑指Offer)面试题46:求1+2+3+....+n
  6. JavaScript数组去重的常用方法
  7. 数据库---基础知识
  8. express怎么读取html,Express 配置HTML页面访问的实现
  9. 读取swagger配置文件里的内容
  10. http与https的作用与区别