This is a migrated thread and some comments may be shown as answers.

Retrieving RawData from Report

4 Answers 290 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
P.
Top achievements
Rank 2
P. asked on 29 Jun 2011, 06:58 PM
I would like to dump the raw data that is used to create a report to Excel.
My intent is to be able to dump the raw data that feeds a report, be it a top level report, or a drill - through report (a report called by another report).  How can I retrieve the raw data that feeds the currently viewed report?

Telerik Reporting 2011 Q1 5.0.11.603
VS 2008 using WebForms
All reports datasources are SQLDatasource Stored Procedures with the report parameters fed from the application to the report object


The following is the method I am currently using for the top level report only.
Protected Sub btnDumpToExcel_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnDumpToExcel.Click
    Dim RunRpt As String = Me.ReportViewer1.Report.Reports(0).Name
 
    Dim tb As New DataTable(RunRpt)
    Dim dataConn As New SqlConnection
 
    Select Case RunRpt
        Case "evRptBehaviorChange"
            Dim report1 As Snap_EvalReports.evRptBehaviorChange = ReportViewer1.Report.Reports(0)
            With report1
                Dim xSQLDatasource As Telerik.Reporting.SqlDataSource = .DataSource
                Dim SQLConnectionString As String = System.Configuration.ConfigurationManager.ConnectionStrings(xSQLDatasource.ConnectionString).ToString
 
                Dim xSelectCommand As String = xSQLDatasource.SelectCommand
 
                dataConn.ConnectionString = SQLConnectionString
                dataConn.Open()
                Dim sdc As SqlCommand = New SqlCommand(xSelectCommand, dataConn)
                sdc.CommandTimeout = LengthOfTimeOut
                sdc.CommandType = CommandType.StoredProcedure   'xSQLDatasource.SelectCommandType
 
                For Each p As Telerik.Reporting.SqlDataSourceParameter In xSQLDatasource.Parameters
 
                    Dim xParam As SqlParameter = New SqlParameter(p.Name, p.GetType)
                    sdc.Parameters.Add(xParam)
                Next
 
                '                       ALTER   PROCEDURE [dbo].[StoredProcedure1]
                '(@FiscalYearID      int=3)
                sdc.Parameters.Item("@FiscalYearID").Value = CType(Session("spaFiscalYear"), Integer)
                Dim sda As SqlDataAdapter
                sda = New SqlDataAdapter(sdc)
                sda.Fill(tb)
                dataConn.Close()
                dataConn = Nothing
                XLSExport(tb, RunRpt)
            End With
    End Select
End Sub

Thank you in advance.

Patti

4 Answers, 1 is accepted

Sort by
0
Massimiliano Bassili
Top achievements
Rank 1
answered on 01 Jul 2011, 03:07 PM
Exporting to CSV gets you data as raw as it gets :D From there on, what you do with the data is up to you. Generally the main purpose of CSV format is to transfer data between different information systems e.g. import in MS Excel or Word, so you can definitely do it. One thing you have not shared is why you're not using the built-in export to excel ..

Cheers!
0
P.
Top achievements
Rank 2
answered on 01 Jul 2011, 05:20 PM
Massimiliano, thank you for your post.

The CSV dumps only the cells/textboxes that appear on the report. I want to dump the RAW data from the stored procedure that feeds the report; the CSV export does not do this.

Why I have not used the Excel export is because it is only an image of the report, and it does not serve my purpose for data analysis. 


I have two types of users, and their uses do overlap:
  1. the user who is viewing reports and distributing them to others
  2. the user that does their own data analysis on the raw data.

Attached is an Excel file showing a sample of the Report CSV export verses the raw stored procedure data. I want the data from the raw stored procedure.

Thanks.
Patti
0
Steve
Telerik team
answered on 04 Jul 2011, 08:39 AM
Hello Patti,

According to the additional information you've provided, you do not need to go through Telerik Reporting for this at all. Check the following post for more information.

Best wishes,
Steve
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
P.
Top achievements
Rank 2
answered on 08 Jul 2011, 05:19 PM
Hi all. 

My ultimate goal is to gather information from the Telerik ReportViewer currently viewed report, and generate an Excel dump of the report's raw data. The problem was, I was using the Telerik.Reporting.SqlDataSourec.Parameters to find values of the parameter values sent from the main program to the report; and I should have been using Telerik.Reporting.ReportParameterCollection.

I have this working for a single level report, and have yet to implement it for a drill-through report, and a multi-datasource report. Please realize, all my reports are populated by stored procedures.

Here is the code. I hope it helps someone.
Protected Sub btnDumpToExcel_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnDumpToExcel.Click
    Dim RunRpt As String = Me.ReportViewer1.Report.Reports(0).Name
 
    Dim tb As New DataTable(RunRpt)
    Dim dataConn As New SqlConnection
    Dim report1 As Telerik.Reporting.Report = Me.ReportViewer1.Report.Reports(0)
 
    With report1
        Dim xSQLDatasource As Telerik.Reporting.SqlDataSource = .DataSource
        Dim SQLConnectionString As String = System.Configuration.ConfigurationManager.ConnectionStrings(xSQLDatasource.ConnectionString).ToString
        Dim xSelectCommand As String = xSQLDatasource.SelectCommand
 
        dataConn.ConnectionString = SQLConnectionString
        dataConn.Open()
        Dim sdc As SqlCommand = New SqlCommand(xSelectCommand, dataConn)
        sdc.CommandTimeout = LengthOfTimeOut
        sdc.CommandType = CommandType.StoredProcedure
        Dim RPColl As Telerik.Reporting.ReportParameterCollection = report1.ReportParameters
 
        For Each rp As Telerik.Reporting.ReportParameter In RPColl
            Dim xParam As SqlParameter = New SqlParameter(rp.Name, rp.Value)
            sdc.Parameters.Add(xParam)
        Next
 
        Dim sda As SqlDataAdapter
        sda = New SqlDataAdapter(sdc)
        sda.Fill(tb)
        dataConn.Close()
        dataConn = Nothing
        XLSExport(tb, RunRpt)
    End With
End Sub
Thanks.

Patti
Tags
General Discussions
Asked by
P.
Top achievements
Rank 2
Answers by
Massimiliano Bassili
Top achievements
Rank 1
P.
Top achievements
Rank 2
Steve
Telerik team
Share this question
or