问题描述
我们正在将报表服务器从SSRS 2005升级到SSRS 2008 R2.
我对SSRS 2008的CSV导出渲染有一个问题,其中列的SUM在2008年的明细值的右侧而不是在2005年的左侧,如下面的块所示,显示在明细值的右侧.117
和131
分别是Column2和Column3的总和.
We are upgrading our report server from SSRS 2005 to SSRS 2008 R2.
I have an issue with CSV export rendering for SSRS 2008 where the SUM of columns are appearing on the right side of the detail values in 2008 instead of the left side like in 2005 as shown in the below blocks.117
and 131
are the sums of Column2 and Column3 respectively.
SSRS 2005 CSV输出
Column2_1,Column3_1,Column2,Column3
117,131,1,2
117,131,1,2
117,131,60,23
117,131,30,15
117,131,25,89
SSRS 2008 CSV输出
Column2,Column3,Column2_1,Column3_1
1,2,117,131
1,2,117,131
60,23,117,131
30,15,117,131
25,89,117,131
I understand that the CSV renderer has gone through major changes in SSRS 2008 R2 with the support for charts and gauges and more importantly it provides 2 modes: the default Excel
mode and Compliant
mode. But neither mode helps fix this issue. The Compliant mode was supposed to be closest to that of 2005 but apparently it is not close enough for my case.
我的问题:
有没有一种方法可以强制SSRS 2008将报告回退到向后兼容模式,以便将其导出为2005 CSV格式?
My Question:
Is there a way to force SSRS 2008 fall back a report to a backward compatibility mode so that it exports into a 2005 CSV format?
尝试过的解决方案:
a)使用基于2005的CRI
根据有关ExecutionLog2的这篇文章,如果SSRS 2008 R2遇到无法自动升级的报告(例如,使用基于2005的CustomReportItem控件构建的报告),则这些特定报告将由旧的Yukon引擎以透明的向后兼容模式"进行处理.
Solution tried:
a) Using 2005-based CRIs
Based on this article on ExecutionLog2, if SSRS 2008 R2 encounters a report whose auto-upgrade is not possible (e.g. reports that were built with 2005-based CustomReportItem controls), those particular reports will be processed with the old Yukon engine in a "transparent backwards-compatibility mode".
似乎它退回到其先前的版本模式(2005)并尝试呈现它.因此,我尝试使用基于2005的条形码CustomReportItem并将其部署到SSRS 2008 R2报表服务器,但是它显示了与以前相同的结果,尽管它抑制了条形码.这是因为SSRS 2008 R2找到了一种抑制部分报告输出并显示其余部分的方法.最好找到一个基于2005的CRI,它使SSRS 2008 R2使用其旧的Yukon引擎对其进行处理.请注意,即使它使用旧的Yukon处理引擎",也很有可能仍会使用新的CSV渲染器,因此它显示相同的输出.如果是这样,那么此选项没有意义.
It seems like it falls back to its previous version mode (2005) and attempts to render it.So I tried using a 2005-based barcode CustomReportItem and deployed to a SSRS 2008 R2 report server, but it shows the same result as before though it suppressed the barcode. This would be because SSRS 2008 R2 finds a way to suppress part of the report output and displays the rest.It would be great to find a 2005-based CRI that makes SSRS 2008 R2 process it with its old Yukon engine.Please note that quite possibly, even if it uses the "old Yukon processing engine", it might still use the new CSV renderer hence it shows the same output. If that is true, then this option is moot.
b)使用XML渲染器
我们可以使用自定义XML渲染器,然后使用XSLT将xml转换为适当的CSV,但这意味着我们需要转换所有200个报告.因此,这是不可行的.
b) Using XML renderer
We can use a custom XML renderer and then use XSLT to convert the xml to appropriate CSV but this would mean that we need to convert all our 200 reports. Hence this is not feasible.
请注意,我们不能选择并排部署SSRS 2005和SSRS 2008 R2.
Please note that we do not have the option of having SSRS 2005 and SSRS 2008 R2 deployed side by side.
推荐答案
您的问题促使我终于走出去,尝试编写自定义RenderingExtension .答案是创建一个包装"旧的SSRS 2005 CSV呈现扩展名的扩展名,并在SSRS 2008中以新名称使用该扩展名.
Your question triggered me to finally go out and try to write a custom RenderingExtension. The answer here would be to create an extension that "wraps" the old SSRS 2005 CSV rendering extension and makes it available under a new name in SSRS 2008.
我当然认为有可能做到这一点.不幸的是,我没有2005 SSRS DLL,因此我通过创建一个包装了 2008 CSV渲染器的扩展程序来进行了概念验证.经过一番奋斗,我终于把它付诸实践.也许此答案将帮助您类似地为2005 CSV渲染器实施此操作.
I certainly think it's possible to do this. Unfortunately, I don't have the 2005 SSRS DLL's, so I did my proof of concept by creating an extension that wraps the 2008 CSV renderer. After quite a struggle I finally got this to work. Maybe this answer will help you in implementing this analogously for the 2005 CSV renderer.
一些注意事项:
- 所有工藤应该去" Broes ",他在自己的博客上写了一篇关于类似案例的出色教程.关于PDF水印(第1部分,第2部分),这对于创建扩展名非常重要.
- Microsoft警告关于编写"Writing的扩展名自定义渲染扩展很困难".,即使他们谈论的是实际上确实可以实现某些功能的扩展(除了包装默认扩展之外),我发现只要让它正常工作就可以也会很痛苦.
- All kudo's should go to "Broes", who wrote an excellent tutorial on his blog for a similar case on PDF watermarks (part 1, part 2), which was invaluable in creating the extension.
- Microsoft warns about writing an extension that "Writing a custom rendering extension is difficult", and even though they're talking about an extension that actually does something (besides wrapping a default extension), I found just getting the thing to work can be quite a pain as well.
这是基本步骤:
- 使用新类创建新类库(.NET 3.5,而不是4.0 +)(请参见下面的代码).
- 添加引用至:
- Create a new class library (.NET 3.5, not 4.0+) with a new class (see code below).
- Add a reference to:
- Microsoft.ReportingServices.DataRendering(用于默认的CSV渲染器)
- Microsoft.ReportingServices.Interfaces
- Microsoft.ReportingServices.ProcessingCore
rssrvpolicy.config
文件以包括程序集在CodeGroup元素中.rsreportserver.config
文件以包括扩展名.rssrvpolicy.config
file to include your assembly in a CodeGroup element.rsreportserver.config
file to include the extension.以下是包装默认CSV渲染器的类的代码清单:
Here's the code listing for the class that wraps the default CSV renderer:
using Microsoft.ReportingServices.Interfaces;
using Microsoft.ReportingServices.OnDemandReportRendering;
namespace Ssrs2005CsvRenderingExtension
{
public class Csv2005Renderer : IRenderingExtension
{
private IRenderingExtension oldskoolCsvRenderer;
public Csv2005Renderer()
{
oldskoolCsvRenderer = new Microsoft.ReportingServices.Rendering.DataRenderer.CsvReport();
}
public void GetRenderingResource(CreateAndRegisterStream createAndRegisterStreamCallback,
System.Collections.Specialized.NameValueCollection deviceInfo)
{
oldskoolCsvRenderer.GetRenderingResource(createAndRegisterStreamCallback, deviceInfo);
}
public bool Render(Microsoft.ReportingServices.OnDemandReportRendering.Report report,
System.Collections.Specialized.NameValueCollection reportServerParameters,
System.Collections.Specialized.NameValueCollection deviceInfo,
System.Collections.Specialized.NameValueCollection clientCapabilities,
ref System.Collections.Hashtable renderProperties,
CreateAndRegisterStream createAndRegisterStream)
{
return oldskoolCsvRenderer.Render(report,
reportServerParameters,
deviceInfo,
clientCapabilities,
ref renderProperties,
createAndRegisterStream);
}
public bool RenderStream(string streamName,
Microsoft.ReportingServices.OnDemandReportRendering.Report report,
System.Collections.Specialized.NameValueCollection reportServerParameters,
System.Collections.Specialized.NameValueCollection deviceInfo,
System.Collections.Specialized.NameValueCollection clientCapabilities,
ref System.Collections.Hashtable renderProperties,
CreateAndRegisterStream createAndRegisterStream)
{
return oldskoolCsvRenderer.RenderStream(streamName,
report,
reportServerParameters,
deviceInfo,
clientCapabilities,
ref renderProperties,
createAndRegisterStream);
}
public string LocalizedName
{
get { return "Oldskool CSV renderer"; }
}
public void SetConfiguration(string configuration)
{
oldskoolCsvRenderer.SetConfiguration(configuration);
}
}
}
这是添加到rsreportserver.config
的扩展名:
<Extension Name="OLDSKOOLCSV" Type="Ssrs2005CsvRenderingExtension.Csv2005Renderer,Ssrs2005CsvRenderingExtension"/>
这是我使用的rssrvpolicy.config
的配置xml:
And this is the configuration xml for rssrvpolicy.config
as I used it:
<CodeGroup
class="UnionCodeGroup"
version="1"
PermissionSetName="FullTrust"
Name="OldskoolCsvGroup"
Description="Code group for oldskool csv extension">
<IMembershipCondition
class="UrlMembershipCondition"
version="1"
Url="C:\Program Files\Microsoft SQL Server\MSRS10.SQLSERVER\Reporting Services\ReportServer\bin\Ssrs2005CsvRenderingExtension.dll"
/>
</CodeGroup>
一个对快速测试是否有用的脚本非常有用(主要是因为它涉及大量的试验和错误),我使用 RS实用工具:
One script that was very useful for quick testing if things worked (mainly because it involved a lot of trial and error), which I execute with the RS Utility:
Public Sub Main()
Dim items() As Extension
items = rs.ListExtensions(1)
For Each item As Extension In items
Console.WriteLine(item.Name)
Next item
End Sub
就是这样.经过数小时的反复试验,至少这是我仍然记得的所有重要内容.完成最后的笔记:
And that's it. At least it's all the important stuff I can still remember after a few hours of trial and error. To finish with one final note:
- 应用程序事件日志有时包含SSRS错误.其中之一是"SSRS无法加载...扩展名".这是我清除的最后一个障碍,我通过将目标框架从 .NET 4.0更改为3.5 来清除了它.
- The Application Event Log sometimes contains SSRS errors. One of them was "SSRS cannot load the ... extension". This was the last hurdle I cleared, and I cleared it by changing the target framework from .NET 4.0 down to 3.5.
任何人都应该使用实际的2005 CSV渲染DLL尝试此操作:让我们知道它是否成功通过注释或对答案的编辑.
Should anyone attempt this with the actual 2005 CSV rendering DLL: let us know whether it was succesful with a comment or an edit to the answer.
这篇关于强制SSRS 2008使用SSRS 2005 CSV呈现的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!