Reporting report development knowledge merge [personal original]

[ Personal original ], please forward the statement description link

To understanding

a) SSRS full name of the SQL Server Reporting Services, is dependent on the operation of the database, it is developed by Microsoft BI product weight class

b) easy to get started, the development of simple, there is a database server can be, and need not rely on IIS to run

c) scalability is relatively low, compared to those of other reports, it is indeed better

d) can be run on a separate server SqlServer, may be embedded into the project

 

Reporting Structure

Reporting by viewing the report, a complete report, the report contains some configurations (default font style, automatic refresh, the language, the container blank, unit type report, the report ID), data sources, data collection, reporting section (corresponding to the container) , report parameters, report layout parameters these main components, there will be different according to reporting style of different components, such as a picture embedded in the report, it will be more a picture embedded structure

 

Report Layout

Limited to the header and footer data subject can not be used, such as page numbers, the report will lead to error

 

  Built-in fields in the report data, all of which may be placed into the header and footer, the body portion may be placed

The data is limited to the body, not directly on the header and footer, the header may be implemented is now by polymerization, such as sum, average, etc.

 

  In the packet data, not directly into the header and footer, the packet can be paged and display First (field names) displayed in the header or footer

Report style

  Here are all the report's page layout controls

  

 

 

development tools

a) There are two ways to develop the report. One is the SSRS, this is the direct use Reporting Services to create reports; another is the SSDT, is an independent development tools,

 

b) In SqlServer2012 previous versions (including SqlServer2012), the installation of the database can install SQL Server Business Intelligence Development Studio and Sql Server Reporting Service. After SqlServer 2012, SSDT is the need to install separate

 

 

Configuring SSRS

a) configure SSRS server, open the Reporting Server Configuration Manager, select the report server instance

 

 

b) Configure the local server, you can use the built-in account, and if others use, select Configure other accounts, other accounts, note the user name format Domain / User name, I do not know what you can look at your system Description, saving keys, confirm

 

 

c) Select the Web service URL Click Advanced, you can add, you can modify the

 

 

d) changes to the database, local server, like the default, remote server, requires reporting mode Sql account credentials also

 

 

e) Web portal URL: SSRS Report Manager is to configure your pages, the configuration is complete, now you can visit

Creating a simple report

SSRS way

                i. Open your SSRS administration page, click on the top right corner of the new document plus sign (New) clips and reports, before SqlServer2012, click Add a report, after 2016 and 2016, the report distinguishes between mobile, paging Report

               ii. Click the plus sign (new), can create a new folder, KPI report, the mobile reports, the report pages, data sources, data sets

       

 

              iii.          Paging report

              . Iv New Report page opens Reporting Builder, no words in the pop-up page and select Get Reporting Builder;

               v. In the first Reporting Builder will give you a pop-up wizard, a forms a matrix, charts, maps, guide, blank report

       

 

              vi. First, choose to create a data set (you can use a shared set of data),

            vii. Then, to create a data source, click New input connection string, or string generated

           viii. The third step, by creating Sql complete data set, by visualization, can also click edit text input sql

(在这里需要的是,字段名称不能有重复的,不能同时写两个以上的查询语句或不能包含函数操作类的语句)

              ix.          第四部,分组

      

 

               x.          第五步:选择布局

              xi.          SqlServer2012之前会有第六步选择样式外观

            xii.          最后点击完成,这样,一个最简单的报表就出来了

SSDT方式(支持中文)

           xiii.          Sqlserver2012(包含)之前的版本,打开SQL Server Business Intelligence Development Studio,选择商业智能项目,创建报表服务项目

           xiv.          VS2017(包含)之后,打开VS,打开VS2017或VS2017 SSDT,选择商业智能项目,创建报表服务项目

你的电脑数据库为2016/2017的,VS为2017以下的,抱歉了,只能通过SSRS创建报表

            xv.          选择项目路径以及名称

           xvi.          打开解决方案资源管理器,右击报表,选择添加新报表

          xvii.          选择或新建数据源,点击编辑可以生成连接字符串

        xviii.          输入查询的sql语句

           xix.          选择表格或矩阵

            xx.          分组

           xxi.          输入报表名称

报表数据

a)     报表数据在窗口的左侧,要是找不到了,没关系,在工具栏-视图-最下面的报表数据

 

 

 

b)     在实际工作中,我们有很多要带条件的报表,这就是报表参数

报表参数在Report报表中生成一个供用户输入数据的框,比如下面这个例子

 

 

 

参数对接到Sql,在Sql中就是不带声明的局部变量

SELECT @NAME NAME,@SEX SEX,@AGE AGE,@LIKE [LIKE],@BRITHDAY BRITHDAY

报表分组分页

分组

a)     在Report中,分组方式有行组和列祖,一般的分组分页指的是行组

以下方数据做分页报表

 

 

b)     通过创建报表导航添加报表分组,SSRS分组和SSDT分组通过导航分组的时候有点差异,需要区别一下

          xxii.          SSDT方式

  1. 选择表格

 

 

 

  1. 把相应的字段放入对应的位置中

 

 

  1. 选择样式和是否包含小计

  

 

        xxiii.          SSRS通过导航来分组

  1.  输入Sql,然后把字段放入对应的字段(SSRS没有直接的分页)

 

 

c)     高手操作手动分组

                i.          上面的分组是最简单的,一下才是分组分页的核心

               ii.          下面是对报表数据的分组分页,先展示一下分组前的报表

 

 

              iii.          右击表格左框,点击添加组

 

 

在这里看到了有子组和父组,子组是在当前下的组内部的数据再次分组;

父组是对于一类型的数据放在一起组合起来的分组

              iv.           因为我们是要从小往大分,对于苹果,香蕉这一类的数据进行分组,所以点击添加父组

               v.           在分组依据中选择对应的分组字段 CLASS3,添加组尾以方便我们显示小计

组头相当于表格的标题头,组尾就是表格最后用于汇总的尾

 

 

 

 

              vi.          分组效果如下

 

 

            vii.          组内排序

 

 

分页

分页是在分组属性中选中分页符,勾选分页,那么一组就会分一页

常用的报表函数

时间日期类

                i.          获取当前时间日期,Now(),使用方法 =Now()

               ii.          获取当前日期,Today() 例子: =Today()

              iii.          格式化字符串,Format(时间,格式) 例子:=Format(Now(),”MM/dd/yyyy hh:mm:ss tt”)

数学类

                i.          加减乘除  +  -  *  /

               ii.          列(组)求和Sum() 例子 =Sum(Parameters!Quantity.Value)

              iii.          列(组)平均值Avg() 例子 =Avg (Parameters!Quantity.Value)

              iv.          列(组)最大值最小值 例子 =Max(Parameters!Quantity.Value)

=Max(Parameters!Quantity.Value)

               v.          求余 Mod 例子 = 5 Mod 2

 

              vi.          列(组)第一个值First() 和 最后一个值Last() 例子

=First(Parameters!Quantity.Value)

=Last(Parameters!Quantity.Value)

            vii.          计数Count()和CountDistinct()

记录数据的数量,包含重复不包含NULL的 Count()

记录不重复数据的数量,不包含NULL的CountDistinct()

表格类

                i.           行号 RowNumber() 返回当前组内第几条数据

               ii.           报表开始运行时间 Globals!ExecutionTime

              iii.           报表总页码 Globals!OverallPageNumber ,只能用于页眉和页脚

              iv.           当前页码 Globals!PageNumber,只能用于页眉和页脚

流程

                i.          判断 IIF

IIF(1>2,”正确”,”错误”)

               ii.          流程控制

Switch(Fields!FirstName.Value = “Sue","Susan",

Fields!FirstName.Value = "Bob","Robert")

字符串处理

                i.          字符串切割 Split()函数

a)     返回包含指定数量子字符串的以零为基的一维数组。

b)     常用成员

                         i.          获取切割后返回数组中某个下标值的Value值  GetValue(下标值)

例子: = Split(“12^34^56”,”^”). GetValue(0)   返回值为 12

                        ii.          获取切割后返回数组的长度 Length

例子: = Split(“12^34^56”,”^”). Length    返回值为 3

 

支持的Html元素

在Report报表中支持部分的html元素的显示

标签

                i.          支持常用的标签

<b>b</b> <p>p</p> <h1>h1</h1> <h2>h2</h2> <h3>h3</h3> <h4>h4</h4> <h5>h5</h5> <h6>h6</h6> <span>span</span> <strong>strong</strong> <i>i</i> <div>div</div> <a href=>a</a> 等等

支持ul li 无序列表

支持ol li 有序列表 不支持定义样式

不兼容自定义列表

               ii.          不支持表单类标签

不支持 table tr td 标签

不支持 from 等等

 

样式

              iii.          支持常用的字体样式,

比如字体加粗,字体倾斜,字体颜色

              iv.          不支持块元素样式

比如边框,图片,背景色,宽高

 

Report支持VB语言

报表中插入代码

在报表外空白处右击,选择报表属性,

 

 

点击代码,输入代码

 

 

 

代码例子

切割字符串代码,第一个参数要切割的字符串,第二个参数要分割的分隔符,第三个是下标值,

 

Function SplitStr(Str As String, S As String, Index As Int32) As String

    Dim Temp

    Temp = Split(Str, S)

    Dim Len

    Len = UBound(Temp) - LBound(Temp) + 1

    If Len <= Index Then

        Return ""

    End If

    Return Temp(Index)

End Function

 

在报表中调用代码

在报表中使用代码是 Code.代码方法名(参数para)

 

 

 

报表图片

支持的格式

Report仅支持 image/bmp,image/jpeg, image/gif, image/png和image/x-png格式

其他格式的图片会无法识别

图片的使用

添加外部图像

外部图像就是通过地址来访问的图像,外部图像可以存在于报表服务器上,也可以存在于其他网站上.url支持 http://,https://,ftp://,file,mailto

 

操作:

  1. 右击报表设计视图,选择 ”插入” – “图像”
  2. 在图像选项的”常规”中,输入图像名称,选择”图像源”为”外部”
  3. 在使用此图像中输入url
  4. 设置其他属性

 

  1. 点击确定

 

  1. 调整大小

在报表中嵌入图像

嵌入图像是直接把图片转换成base64直接内嵌到Report中,会增大报表的文件大小

 

 

操作:

  1. 右击报表设计视图,选择 ”插入” – “图像”
  2. 在图像选项的”常规”中,输入图像名称,选择”图像源”为”嵌入”
  3. 在使用此图像后面点击导入
  4. 悬着你要导入的图片
  5. 设置其他属性
  6. 点击确定
  7. 调整大小

 

 

导入后的图片存放于报表内部的EmbeddedImage 的节点下

      

通过数据库导入图片

注意:这个方式只支持base64字符串的,而且不包含base64数据头的

 

 

操作:

  1. 右击报表设计视图,选择 ”插入” – “图像”
  2. 在图像选项的”常规”中,输入图像名称,选择”图像源”为”数据库”
  3. 在使用此字段后面选择字段
  4. 在使用此MIME类型后面选择base64的图片格式

 

  1. 悬着你要导入的图片

 

  1. 设置其他属性

 

  1. 点击确定

 

  1. 调整大小

 

 

条形码

使用第三方控件

查阅了国内外大多数网站,Reporting 报表条形码控件做的不错的是Barcode Professional for Reporting Services

下载安装好后再SSDT工具栏添加安装后得到的Dll文件,这时,工具箱里会多一个Barcode Professional for Reporting Services,拖进报表中就可以使用了

使用条形码字体

这里使用了最常用的Code128,由于完整的Code128包括头尾和校验码,所以对数据进行处理

处理数据的Code128 代码

 

 

Code 128 fonts use

Download Code 128 fonts from the Internet

 (Internal company documents, extract contact)

 

Set in a report

 

  1. Code128A calling code added to the data head and tail together checksum
  2.  

  b. Set the font Code128, change the font size

 

 

It should be noted that the language of the report can not be zh-cn, I emptied directly to the

Guess you like

Origin www.cnblogs.com/linjierd/p/11269386.html