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
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
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))
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
Thank you
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
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
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