登录
注册
论坛
空间
帮助
会员
界面
简洁版本
在线
微软BI开拓者
前端应用专区
SQL Server Reporting Services
SSRS: Create and Call a Custom Assembly
数据库专区
SQL Server管理
SQL Server开发
SQL Azure云数据库
商业智能综述区
BI探讨
BI项目管理
数据仓库专区
ETCL设计
SSIS使用与管理
SSIS二次开发
多维分析专区
多维建模
SSAS配置管理
MDX
SSAS二次开发
数据挖掘专区
数据挖掘建模
DMX
DM应用开发
前端应用专区
SharePoint Excel PowerPivot
SQL Server Reporting Services
PerformancePoint及其相关产品
其他
站务
灌水区
培训相关
求职招聘区
1
/ 1 页
1
跳转
页
查看:
5667
SSRS: Create and Call a Custom Assembly
本主题由 管理员 Administrator 于 8/12/2007 10:47:19 PM 执行 设置精华/取消 操作
www2002
个人空间
组别:
新手上路
性别:
来自:
积分:
46
帖子:
98
注册:
2007-04-30
2007-06-13 06:17
|
只看楼主
树型
|
收藏
|
小
中
大
1
SSRS: Create and Call a Custom Assembly
最近做报表,在网上搜了些文章,贴在这里,希望这里越来越旺
SQL Server Reporting Services: Create and Call a Custom Assembly
In one of my previous articles I explained how to use embedded code in SQL Server Reporting Services. The possibility to add embedded code to a report, is a very powerfull feature to add some custom functionality to your report.
But sometimes it might be necessary to add some custom functionality that is too complicated for embedded code to handle efficiently, or you need to access the same function from multiple reports, or you would like to write you code in C#...
In one of these cases you should develop a custom assembly to call from your report.
Let’s start with a simple example and develop a function PercentageToColor() to return a color based on a numeric value representing a percentage.
namespace
MyAssembly
{
public
class
Colors
{
public
string
PercentageToColor(
double
percentage)
{
string
returnValue =
string
.Empty;
if
(percentage < 20)
{
returnValue =
"red"
;
}
else
if
(percentage < 80)
{
returnValue =
"blue"
;
}
else
{
returnValue =
"green"
;
}
return
returnValue;
}
}
}
Once you’ve compiled your class you need to copy the resulting assembly to the directory in which it is accessible from within your report:
·
To use it in the report designer, you need to copy it to:
C:\Program Files\Microsoft Visual Studio 8\Common7\IDE\PrivateAssemblies
·
To make it available for reports that have been deployed to the report server, you need to copy it to:
C:\Program Files\Microsoft SQL Server\MSSQL.3\Reporting Services\ReportServer\bin
Before you can access your custom assembly you have to reference the assembly: Open the report properties (Menu:
Report – Report Properties
) and select the References tab.
Browse to your assembly and define a Class Name and an Instance Name. (The Class Name and the Instance Name or only for non-static methods). Make sure to prefix your class name with the assembly name.
Now you can call the methods in your assembly from your report, using an expression:
·
To call a static method:
= <AssemblyName>.<ClassName>.<StaticMethodName>
·
To call an instance method:
=Code.<InstanceName>.<;PublicMethodName>
So in our example this would be:
=Code.TestColor.PercentageToColor(
Fields!Percentage.Value
)
That's it! You've just created and called a custom assembly from your report...
In one of my future articles I will explain how to pass parameters to the class constructor and I will also tell something about SSRS and .Net Permissions...
原文在这里
http://geekswithblogs.net/davyknuysen/archive/2007/03/26/109901.aspx
拓狼 最后编辑于 2007-06-13 10:06:26
发送短消息
查看公共资料
查找该会员全部帖子
UID:
52
精华:
5
威望:
12
金钱:
46.35 元
ProSrv-:
0
状态:
离线
www2002
个人空间
组别:
新手上路
性别:
来自:
积分:
46
帖子:
98
注册:
2007-04-30
2007-06-13 06:41
|
只看楼主
树型
|
收藏
|
小
中
大
2
回复: SSRS: Create and Call a Custom Assembly
报告班主任,上面那贴中冒出个小家伙在笑话俺。
还有个小小的bug,帖子编辑完后,下面的按钮应该叫“发布...”什么的,现在显示的是“编辑帖子”。
俺们脑子慢,愣看了3分钟才醒过闷儿来。俺们兄弟批评俺:"就这脑袋,还编程?怯!"
发送短消息
查看公共资料
查找该会员全部帖子
UID:
52
精华:
5
威望:
12
金钱:
46.35 元
ProSrv-:
0
状态:
离线
拓狼
个人空间
组别:
管理员
性别:
来自:
北京 海淀
积分:
1121
帖子:
619
注册:
2007-05-23
2007-06-13 10:08
|
树型
|
收藏
|
小
中
大
3
回复: SSRS: Create and Call a Custom Assembly
楼主在发贴的时候,左边有个这样的图,选中图中已选中的那个复选框就OK啦
附件:
您所在的用户组无法下载或查看附件
虽有智慧,不如乘势;虽有鎡基,不如待时。
君子学以聚之,问以辨之,宽以居之,仁以行之。
独学而无友,则孤陋而寡闻。
发送短消息
查看公共资料
查找该会员全部帖子
UID:
6
精华:
81
威望:
172
金钱:
1220.95 元
ProSrv-:
100
状态:
离线
group4968@xiaoi.com
494887861
Administrator
Administrator
个人空间
组别:
管理员
性别:
来自:
积分:
104
帖子:
290
注册:
2007-05-22
2007-06-13 10:26
|
树型
|
收藏
|
小
中
大
4
回复: SSRS: Create and Call a Custom Assembly
顶...
谢谢楼主。:lol
发送短消息
查看公共资料
查找该会员全部帖子
UID:
1
精华:
5
威望:
14
金钱:
104.15 元
ProSrv-:
0
状态:
离线
jinligang
金立钢
个人空间
组别:
管理员
性别:
生日:
1978-2-24
来自:
积分:
14
帖子:
46
注册:
2007-05-23
2007-06-21 22:40
|
树型
|
收藏
|
小
中
大
5
回复: SSRS: Create and Call a Custom Assembly
支持,希望以后能有更多更好的文章。谢谢ww2002!
发送短消息
查看公共资料
查找该会员全部帖子
UID:
4
精华:
4
威望:
8
金钱:
13.75 元
ProSrv-:
0
状态:
离线
jinligang1@sohu.com
Administrator
Administrator
个人空间
组别:
管理员
性别:
来自:
积分:
104
帖子:
290
注册:
2007-05-22
2007-12-27 17:10
|
树型
|
收藏
|
小
中
大
6
回复:SSRS: Create and Call a Custom Assembly
可惜SSIS2005的EXPRESSION不能扩展,只能在自定义组件和自定义脚本里使用自定义托管代码
发送短消息
查看公共资料
查找该会员全部帖子
UID:
1
精华:
5
威望:
14
金钱:
104.15 元
ProSrv-:
0
状态:
离线
<<
上一主题
|
下一主题
>>
1
/ 1 页
1
跳转
页
论坛跳转...
数据库专区
SQL Server管理
SQL Server开发
SQL Azure云数据库
商业智能综述区
BI探讨
BI项目管理
数据仓库专区
ETCL设计
SSIS使用与管理
SSIS二次开发
多维分析专区
多维建模
SSAS配置管理
MDX
SSAS二次开发
数据挖掘专区
数据挖掘建模
DMX
DM应用开发
前端应用专区
SharePoint Excel PowerPivot
SQL Server Reporting Services
PerformancePoint及其相关产品
其他
站务
灌水区
培训相关
求职招聘区
内务
服务测试区
我的主题
我的帖子
我的精华
我的空间
帖子标题
空间日志
相册标题
作 者
我的主题
我的帖子
我的附件
我的精华
我的空间