I have a VB.NET web application (4.0) Telerik Reporting Q1 2013. What I need to do is something like tabs in excel where each tab is a different date. I have datatables to bind the report to. The online documentation is not as good as I hoped it would be so any direction would be greatly appreciated.
Thanks
13 Answers, 1 is accepted

Have you reviewed the "Report Book" options? I have found that if I export a "Report book", each report becomes a worksheet in the workbook (the filename of the report book). Thus if you create a single report book with 5 reports (consisting of your proposed tabs data), you would end up with a single .XLS document having 5 worksheets in it. The document name of each report becomes the worksheet name in excel.
I use that method to export huge collections of reports.


Well, first, read the documentation on the Telerik Report Book object. It is a superset to the Report object. That is to say it a single document which contains a collection of reports.
Telerik.Reporting.ReportBook ourBook = new Telerik.Reporting.ReportBook();
Telerik.Reporting.Report rpt1 = new Telerik.Reporting.Report();
Telerik.Reporting.Report rpt2 = new Telerik.Reporting.Report();
Telerik.Reporting.Report rpt3 = new Telerik.Reporting.Report();
// at this point each report object should have all of its data and parameters set
// you will obviously need to do that elsewhere
rpt1.DocumentName = "Sheet1";
rpt2.DocumentName = "Sheet2";
rpt3.DocumentName = "Sheet3";
ourBook.Reports.AddRange(new List<Telerik.Reporting.Report>() { rpt1, rpt2, rpt3 });
Telerik.Reporting.Processing.ReportProcessor rProc = new Telerik.Reporting.Processing.ReportProcessor();
Telerik.Reporting.InstanceReportSource irs = new Telerik.Reporting.InstanceReportSource();
System.Collections.Hashtable dinfo = new System.Collections.Hashtable();
irs.ReportDocument = ourBook;
Telerik.Reporting.Processing.RenderingResult result = rProc.RenderReport("XLS", irs, dinfo);
using (System.IO.FileStream fs = new System.IO.FileStream("Myfilename.xls", System.IO.FileMode.Create))
{
fs.Write(result.DocumentBytes, 0, result.DocumentBytes.Length);
fs.Close();
}
Sorry for the C# but that should give you a clue. The end result of that is a a single '.XLS" document containing three worksheets entitled "Sheet1", "Sheet2", and "Sheet3"


I would point out one minor glitch in the process. The "document name" must adhere to the naming conventions of your output format. In the case of Excel you must be 31 or fewer characters and not contain certain special characters. It makes sense however it is annoying to find out the hard way.


Getting an error (see below)
Here is my code:
Dim rptSheet As New Report
rptSheet.DocumentName = tmpStartDate.ToString("MM.dd.yyyy")
rptMSVS.Reports.Add(rptSheet)
Dim rpt As New sbrSummary
rpt.DataSource = dtTop
Dim rptProcessor As New Telerik.Reporting.Processing.ReportProcessor()
Dim instance As New InstanceReportSource()
Dim hshTable As New Hashtable()
instance.ReportDocument = rptMSVS
Error on this line: Object reference not set to an instance of an object.
Dim result As Telerik.Reporting.Processing.RenderingResult = rptProcessor.RenderReport("XLS", instance, hshTable)
The code
Dim
rptSheet
As
New
Report
You need to create a new report, as described in the How To: Create a Report (Visual Studio) help article and then create an instance of that report:
Dim
rptSheet
As
New
MyReport
Regards,
Nasko
Telerik


You seems to have gotten things in reverse. The "rptSheet" is the report you are trying to export. I am guessing you really mean "rpt" (ie sbrSummary).. Your code creates a new instance of the object typed as a Telerik Report however you never define its basic structure as which report, what its structure is and so forth. I believe that is what you meant to do with sbrSummary.
I also do not see any ReportBook object. The report book object is a collection of Report objects which is then exported. You seem to be attempting to export each individual report. That should be done to the report book object not the individual reports.
In this case you can create a new report in Visual Studio from the Add > New Item... > Telerik Report <version> project context menu.
Regards,
Nasko
Telerik

As David suggested previously, you will most probably need to add the sbrSummary report to a report book and render it:
'create an instance of your report and modify its definition if needed
Dim
report =
New
sbrSummary()
report.DocumentName = tmpStartDate.ToString(
"MM.dd.yyyy"
)
report.DataSource = dtTop
'create a report book
Dim
reportBook =
New
ReportBook()
reportBook.Reports.Add(report)
'add other reports to the report book here
Dim
rptProcessor =
New
Telerik.Reporting.Processing.ReportProcessor()
Dim
reportSource =
New
InstanceReportSource()
Dim
hshTable =
New
Hashtable()
reportSource.ReportDocument = reportBook
'render the report book using a report processor object
Dim
result = rptProcessor.RenderReport(
"XLSX"
, reportSource, hshTable)
Regards,
Nasko
Telerik