SSRS常见问题解决方案

在最近的项目里主要负责SSRS部分的东西,期间遇到很多有意思的事情。

1,一个不错的样式: 

主要参数:
1.表头背景色:#DBEEF3
2.表格隔行变色:#F2F2F2
3.font-family:"微软雅黑"
4.font-size:12px
5.border:1px solid #b9bbb8
6,当表格数值为0时,显示空白:单元格的format属性设置为:0.00;-0.00;''

2, 隔行变色:BackgroundColor属性设置为:=Iif(RowNumber(Nothing) Mod 2, "#F2F2F2", "White")
有列组时最好不要这么用,会很难看

3,报表导出只显示EXCEL格式
试图根据HTML中结构通过reportView内部一个元素的ID设置,但是后来发现在不用的机器上存在不一致情况
$("#ctl00_MainContent_ReportViewer1_ctl05_ctl04_ctl00_M
enu div:not(:eq(4))").hide()


---终结解决方案:反射将其他项的m_isVisible设为false
reportint service报表导出只显示EXCEL格式
前端: onprerender="ReportViewer_PreRender"
cs端: protected void ReportViewer_PreRender
(object sender, EventArgs e)
{
foreach (RenderingExtension extension in
ReportViewer1.ServerReport.ListRenderingExtensions())
{
if (extension.Name != "EXCEL")
{
FieldInfo fi = extension.GetType
().GetField("m_isVisible", BindingFlags.Instance |
BindingFlags.NonPublic);
fi.SetValue(extension, false);
}
}

}

4, SSRS 安全除零
①自定义函数
Public Function SafeDivide(ByVal top, ByVal bottom) As
Decimal
If IsNothing(top) Or IsNothing(bottom) Then
Return 0
End If

If bottom = 0 Or top = 0 Then
Return 0
End If

Return top / bottom
End Function
②调用=Code.SafeDivide(top,bottom)

5,SSRS加URL,url中传参
文本框属性--操作--选择‘转到URL’,在选择URL中输入
自己的
=Parameters!URL.Value & "AdjustID=21" & "&CAT="
& Fields!CAT.Value & "&BD="&Fields!BD.Value & "&PU="
&Fields!PU.Value

如果想在新页面打开
="javascript:void(window.open('" &
Parameters!URL.Value & "AdjustID=21" & "&CAT="
& Fields!CAT.Value & "&BD="&Fields!BD.Value & "&PU="
&Fields!PU.Value
& "','_blank'))"

posted on 2013-03-25 15:12  大宇牵着一只狗  阅读(827)  评论(0编辑  收藏  举报

导航