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

Exporting without design time Report Viewer

7 Answers 214 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Jason Tarver
Top achievements
Rank 1
Jason Tarver asked on 02 Aug 2010, 06:10 PM

Hello,

I need to be able to present a user with, say, a list of check boxes which represent individual reports.  The user checks reports of interest and clicks "export" button.  Then, in code behind, I need to be able to dynamically create the multiple selected reports and export each report into an individual Excel worksheet within a single workbook.  The user is then prompted to save the workbook as a result of the browser detected content type.

I have seen an example of this export capability, but it was in conjunction with an existing Report Viewer control already on the page. 

If this is not possible, I think my next solution might be to add Report Viewer control to page design time, then populate it with reports selected by user via the check boxes.  Then, from Report Viewer export utility, create the multiple worksheet/single workbook file.

Thanks in advance for your time.

Jason

7 Answers, 1 is accepted

Sort by
0
Chavdar
Telerik team
answered on 05 Aug 2010, 02:18 PM
Hello Jason Tarver,

It is possible to export a report programmatically without using a ReportViewer control on the page. Please, take a look at the Exporting a report to PDF programmatically KB article for more information. In order to fully achieve your goal, you have to use a ReportBook to add the selected reports. For the export to Excel you have to change the name of the rendering extension to "XLS".

Kind regards,
Chavdar
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
Jason Tarver
Top achievements
Rank 1
answered on 06 Aug 2010, 08:33 PM
Thank you Chavdar for your response.  This has moved me further along and leads me to another question.

I am able to export programatically without a report viewer control using your provided example.  However, the object that I need to export is not a telerik report but a placeholder control which contains a user control.  The user control is either a html table or .net gridview.  In my code below, I instantiate the report and detailsection.  Then I add a panel to the detailsection.  Finally, I add the detailsection to the report.  I found code that gives an example of adding a textbox to the panel, but I need a method for adding a control (placeholder control) into the panel or some other object that I can in turn add to the detailsection of the report.

Dim report As New Telerik.Reporting.Report
Dim detail As New Telerik.Reporting.DetailSection
detail.Name = "report1"
Dim panel1 As New Telerik.Reporting.Panel()
Dim textBox1 As New Telerik.Reporting.TextBox()
panel1.Location = New Telerik.Reporting.Drawing.PointU(New Telerik.Reporting.Drawing.Unit(1, Telerik.Reporting.Drawing.UnitType.Cm), New Telerik.Reporting.Drawing.Unit(1, Telerik.Reporting.Drawing.UnitType.Cm))
textBox1.Location = New Telerik.Reporting.Drawing.PointU(New Telerik.Reporting.Drawing.Unit(0, Telerik.Reporting.Drawing.UnitType.Cm), New Telerik.Reporting.Drawing.Unit(0, Telerik.Reporting.Drawing.UnitType.Cm))
textBox1.Name = "NameDataTextBox"
textBox1.Size = New Telerik.Reporting.Drawing.SizeU(New Telerik.Reporting.Drawing.Unit(5, Telerik.Reporting.Drawing.UnitType.Cm), New Telerik.Reporting.Drawing.Unit(0.6, Telerik.Reporting.Drawing.UnitType.Cm))
textBox1.Style.BorderStyle.Default = Telerik.Reporting.Drawing.BorderType.Solid
textBox1.StyleName = "Data"
panel1.Items.AddRange(New Telerik.Reporting.ReportItemBase() {textBox1})
detail.Items.AddRange(New Telerik.Reporting.ReportItemBase() {panel1})
report.Items.Add(DirectCast(detail, Telerik.Reporting.ReportItemBase))
0
Chavdar
Telerik team
answered on 09 Aug 2010, 09:15 AM
Hello Jason Tarver,

In order to see how the report is generated programmatically and in particular any parts of it you can use the Report Designer to create a report at design time. By examining the code in the InitializeComponent method in the report's designer file (e.g. Report1.designer.vb) you can see how exactly the items are created and added to the Items collection of the respective items. Hope this helps.



Regards,
Chavdar
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
Jason Tarver
Top achievements
Rank 1
answered on 10 Aug 2010, 04:34 PM
Thank you Chavdar for your response.  I viewed the Report1.Designer.vb code and can see how the individual report sections and report items are instantiated.  However, I don't see a specific report item that would allow me to add an existing gridview, via user control, into a report.  None of the report items seem to support this.  Is there a way to add a .net control, such as a gridview, into a report item at run time? 

Thank you
Jason
0
Steve
Telerik team
answered on 12 Aug 2010, 05:13 PM
Hello Jason,

No external controls can be used in Telerik Reporting, only the provided ones listed in Understanding Report Items help article.
It would seem from your intentions that you simply want to print a whole aspx page, which is not the purpose of Telerik Reporting. More info is available in the Telerik Reporting White Paper.

Sincerely yours,
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
Jason Tarver
Top achievements
Rank 1
answered on 14 Aug 2010, 06:17 PM
I have created a report class (RPT_1) as recommended by your best practices.  The report runs when viewed thru the report designer preview pane.  I need to be able to export this report server side without the use of a reportviewer control.  I'm referencing the topic "Exporting a report to PDF programatically" and I think this will work for my requirements.  However, I'm stumped as to how I initialize or bind my report found in the report class to the Telerik.Reporting.Report object that gets passed into the ExportToPDF Sub given in the "Exporting a report to PDF programatically" article.

I have added a reference to the RPT_1/obj/Debug/RPT_1.dll file to the website.

Dim report As New Telerik.Reporting.Report()

I need to now bind report to the report item found in my report class so that I can then call the ExportToPDF Sub.

ExportToPDF(report)

Thank you for your assitance,
Jason
0
Steve
Telerik team
answered on 16 Aug 2010, 07:17 AM
Hi Jason,

Telerik Reports are standard .NET classes, so there is nothing out of the ordinary you should do to achieve this task. You should first reference the class library project in your web site and when you build it, the class library would be compiled and added to its bin folder.
After that the initialization is as with any other class:

Dim report As New MyReportLibrary.RPT_1()
ExportToPDF(report)


All the best,
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
Tags
General Discussions
Asked by
Jason Tarver
Top achievements
Rank 1
Answers by
Chavdar
Telerik team
Jason Tarver
Top achievements
Rank 1
Steve
Telerik team
Share this question
or