如何将SSRS中的报表转换成图片

在SSRS的程序框架下,一张报表有可能被多个客户端以不同的方式应用.譬如: Web页面可能需要HTML格式的报表,而打印时需要emf格式的报表.

在打印报表时,经常会先将它专换成emf格式的图片,再发送给打印客户端使用.那么如何实现之间的转换呢?

 1    
 2  ' ReportingService是由web service的WSDL生成的代理类(Proxy)
 3  Public   Class  RTLReportService
 4           Inherits  ReportingService
 5           Implements  RTSystems.Framework.Reporting.IReportService
 6 
 7           Public   Overloads   Function  Render( ByVal  report  As  Framework.Reporting.IReport)  As   Byte ()()  Implements  Framework.Reporting.IReportService.Render
 8            
 9 
10               Dim  deviceInfo  As   String   =   Nothing
11               Dim   format   As   String   =   " IMAGE "
12               Dim  firstPage  As  [ Byte ]()  =   Nothing
13               Dim  encoding  As   String   =   Nothing
14               Dim  mimeType  As   String   =   Nothing
15               Dim  warnings  As  Warning()  =   Nothing
16               Dim  reportHistoryParameters  As  ParameterValue()  =   Nothing
17               Dim  streamIDs  As   String ()  =   Nothing
18               Dim  pages  As  [ Byte ]()()  =   Nothing
19 
20               '  Build device info based on the start page 
21              deviceInfo  =  [ String ].Format( " <DeviceInfo><OutputFormat>{0}</OutputFormat></DeviceInfo> " " emf " )
22 
23               ' Exectute the report and get page count. 
24               Try
25                   '  Renders the first page of the report and returns streamIDs for 
26                   '  subsequent pages 
27                   ' firstPage = rs.Render(reportPath, format, Nothing, deviceInfo, Nothing, Nothing, _
28                   ' Nothing, encoding, mimeType, reportHistoryParameters, warnings, streamIDs)
29 
30                   ' Replacement code by sjs to handle parameters
31 
32                   Dim  lstParams  As   New  List( Of  ParameterValue)
33 
34                   For   Each  param  As  RTSystems.Framework.Reporting.IReportParameter  In  report.Paramers
35                       Dim  paramValue  As   New  ParameterValue()
36                      paramValue.Name  =  param.Name
37                      paramValue.Value  =  param.Value
38                      lstParams.Add(paramValue)
39                   Next
40 
41                   Dim  parameters()  As  ParameterValue  =  lstParams.ToArray()
42 
43             
44                  firstPage  =   Me .Render(report.ReportName,  format Nothing , deviceInfo, parameters,  Nothing , _
45                   Nothing , encoding, mimeType, reportHistoryParameters, warnings, streamIDs)
46 
47 
48                   '  The total number of pages of the report is 1 + the streamIDs 
49                  m_numberOfPages  =  streamIDs.Length  +   1
50                  pages  =   New  [ Byte ](m_numberOfPages  -   1 )() {}
51 
52                   '  The first page was already rendered 
53                  pages( 0 =  firstPage
54 
55                   For  pageIndex  As   Integer   =   1   To  m_numberOfPages  -   1
56                       '  Build device info based on start page 
57                      deviceInfo  =  [ String ].Format( " <DeviceInfo><OutputFormat>{0}</OutputFormat><StartPage>{1}</StartPage></DeviceInfo> " " emf " , pageIndex  +   1 )
58                       ' pages(pageIndex) = rs.Render(reportPath, format, Nothing, deviceInfo, Nothing, Nothing, _
59                       ' Nothing, encoding, mimeType, reportHistoryParameters, warnings, streamIDs)
60                      pages(pageIndex)  =   Me .Render(report.ReportName,  format Nothing , deviceInfo, parameters,  Nothing , _
61                       Nothing , encoding, mimeType, reportHistoryParameters, warnings, streamIDs)
62                   Next
63 
64               Finally
65 
66               End   Try
67 
68               Return  pages
69           End Function
70 
71       End Class


 

转载于:https://www.cnblogs.com/beiguren/archive/2010/01/13/1646721.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值