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

Need to do something like tabs in EXCEL

13 Answers 224 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Mark
Top achievements
Rank 1
Mark asked on 17 Jun 2015, 07:27 PM

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

Sort by
0
David
Top achievements
Rank 1
Iron
Veteran
Iron
answered on 18 Jun 2015, 03:19 AM

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.

 

 

0
Mark
Top achievements
Rank 1
answered on 18 Jun 2015, 11:04 AM
No I have not as I am doing my first report ever.  So this is foreign to me at this point..  Can you elaborate more on how I can accomplish what you are suggesting?
0
David
Top achievements
Rank 1
Iron
Veteran
Iron
answered on 18 Jun 2015, 01:20 PM

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"

0
Mark
Top achievements
Rank 1
answered on 18 Jun 2015, 01:50 PM
Thanks, Seems just what I need.  No worries about the C# as I code in both.  This job is a VB one.  Will post once I give it a try. 
0
David
Top achievements
Rank 1
Iron
Veteran
Iron
answered on 18 Jun 2015, 01:53 PM

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.

 

0
Mark
Top achievements
Rank 1
answered on 18 Jun 2015, 02:00 PM
Thanks for the tip.  It will be just a date so I should be fine.
0
Mark
Top achievements
Rank 1
answered on 23 Jun 2015, 02:25 PM

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)

0
Nasko
Telerik team
answered on 23 Jun 2015, 02:59 PM
Hello Mark,

The code
Dim rptSheet As New Report
will create a new object of type Telerik.Reporting.Report. However, in this state the object will be empty i.e., it will not contain any report items, report sections, etc.

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
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 Feedback Portal and vote to affect the priority of the items
0
Mark
Top achievements
Rank 1
answered on 23 Jun 2015, 03:03 PM
Thanks for the reply.  I do not have that option in the version I have (see original post).
0
David
Top achievements
Rank 1
Iron
Veteran
Iron
answered on 23 Jun 2015, 03:07 PM

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.

0
Nasko
Telerik team
answered on 23 Jun 2015, 03:08 PM
Hello Mark,

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
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 Feedback Portal and vote to affect the priority of the items
0
Mark
Top achievements
Rank 1
answered on 23 Jun 2015, 03:10 PM
I do have a report created(new page) and a report viewer to test on the same page.  For now I am trying to just show it in the report viewer but if that wont work I am open for the 'right' way :).    Thanks for everyones help.  Being a newbie to reports and telerik this is heading me in the right direction. 
0
Accepted
Nasko
Telerik team
answered on 23 Jun 2015, 03:21 PM
Hello Mark,

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
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 Feedback Portal and vote to affect the priority of the items
Tags
General Discussions
Asked by
Mark
Top achievements
Rank 1
Answers by
David
Top achievements
Rank 1
Iron
Veteran
Iron
Mark
Top achievements
Rank 1
Nasko
Telerik team
Share this question
or