Data Dynamics Reports Support

Started by JG@GC at 11-15-2008 9:42 AM. Topic has 8 replies.

Print Search Rate
Sort Posts:    
   11-15-2008, 9:42 AM
JG@GC is not online. Last active: 11/15/2008 9:34:54 PM JG@GC

Not Ranked
Joined on 11-15-2008
Posts 3
How to open a report directly into excel format, without rendering/viewing it in reportviewer control?

I am looking to open DataDynamics report in excel on the click of a button.
In this process there will be no rendering/viewing in reportviewer control.

In a way i am looking for - How to use DataDynamics.Reports.Rendering.Excel class to open a report directly in xls format.

Any help / guidance will be highly appreciated. Thanks in advance.
   Report 
   11-17-2008, 12:30 AM
IgorI is not online. Last active: 1/25/2010 8:21:51 PM IgorI

Top 50 Posts
Joined on 04-18-2007
Novosibirsk, Russia
Posts 250

DDStaff
Re: How to open a report directly into excel format, without rendering/viewing it in reportviewer control?
Hello,

here is the sample code:

            ExcelTransformationDevice device = new ExcelTransformationDevice();
            ExcelTemplateGenerator template = new ExcelTemplateGenerator();
            MemoryStream templateStream = new MemoryStream();
            ReportDefinition def = new ReportDefinition(new FileInfo(@"TestReport.rdlx"));
            template.GenerateTemplate(def, templateStream);
            templateStream.Position = 0;
            device.TemplateStream = templateStream;
            ReportRuntime runtime = new ReportRuntime(def);
            runtime.Render(device, new FileStreamProvider(new DirectoryInfo(@"\"), "xlsexport.xls"));

Thanks,
Igor

   Report 
   11-17-2008, 10:11 AM
JG@GC is not online. Last active: 11/15/2008 9:34:54 PM JG@GC

Not Ranked
Joined on 11-15-2008
Posts 3
Re: How to open a report directly into excel format, without rendering/viewing it in reportviewer control?
Thanks much.

That seems to be fairly easy. Is there any reference guide, User guide that contains detailed code snippets like this?

I have checked all your forums & online document + Installed documentation, but was not able to locate code snippets to work with DD reports programatically.

Any help will be highly appreciated.

Thanks again!
   Report 
   11-17-2008, 1:53 PM
Jon Smith - DD is not online. Last active: 3/10/2010 1:23:56 AM Jon Smith - DD

Top 25 Posts
Joined on 02-21-2007
Columbus, OH
Posts 778

DDStaff
Re: How to open a report directly into excel format, without rendering/viewing it in reportviewer control?
There are not many code samples in the documentation. Our code samples are installed with the product in My Documents\Data Dynamics\Reports\x.x.xxx.x\Samples\API (where x.x.xxx.x is the build number). If you would like to see a code sample for something that is not provided already, let us know and we'll post one here on the forums and possibly include it in the code samples for the product.

Thanks,
Jon

   Report 
   01-20-2010, 1:58 PM
radhat is not online. Last active: 1/21/2010 3:56:09 AM radhat

Not Ranked
Joined on 07-24-2008
Posts 14
Re: How to open a report directly into excel format, without rendering/viewing it in reportviewer control?
Your code helped out immensely.
I wanted to check for the existance of any data in the report body and export it to exel only if there was at least one row.

I did it this way. Thanks. :)

if(rpt.ReportDefinition.Report.Body.ReportItems.Count > 0)
{
//Let's try to get it to export to excel
ExcelTransformationDevice device = new ExcelTransformationDevice();
ExcelTemplateGenerator template = new ExcelTemplateGenerator();
MemoryStream templateStream = new MemoryStream();

template.GenerateTemplate(rdl, templateStream);
templateStream.Position = 0;
device.TemplateStream = templateStream;
//remember report is rpt
rpt.Render(device, new FileStreamProvider(new DirectoryInfo(path), "TRA_SCCR.xls"));

}
   Report 
   01-20-2010, 11:09 PM
Sergey is not online. Last active: 3/3/2010 9:56:56 PM Sergey

Top 10 Posts
Joined on 08-28-2004
Novosibirsk, Russia
Posts 2,780

DDStaff
Re: How to open a report directly into excel format, without rendering/viewing it in reportviewer control?

Attachment: DDR_NoDataCheck.zip
Hello,
Unfortunately, the way to check the existence of any data in the report which you demonstrated does not seem to be correct.
rpt.ReportDefinition.Report.Body.ReportItems returns the collection of the report items in the body of the report at design time. It does not deal with the report "runtime" items. I.e. if you use the table-based report and there is only table in the report definition, then rpt.ReportDefinition.Report.Body.ReportItems.Count returns 1.
I would like to propose the way to check whether the report's dataset returns at least one row of the data. Let's go throgh the example of the approach I propose.
We need to create the report which shows the certain customer's orders. The customer's id is specified by end-user.
We added the data source which connects to Northwind database and defined Customers dataset with the following query:
select * from Orders where CustomerID=@CustomerID
The CustomerID parameter of the dataset is mapped to the corresponding report parameter.

Now we want to know if there are the orders with customer's id which is specified by end-user.
We can add the new dataset with the following query:
select count(OrderID) as RowsCount from Orders where CustomerID=@CustomerID
Then we can add the report parameter(let's say it is called RowsCount) which gets it's valid values from that dataset.
Then, before run the export(rpt.Render), we can check the parameter's value. It will be exactly the count of rows returned by Orders dataset:

            Parameter customerIdParameter = rpt.Parameters["CustomerID"];
            customerIdParameter.CurrentValue = customerID;
            Parameter rowsCountParameter = rpt.Parameters["RowsCount"];
            object rowsCount = rowsCountParameter.ValidValues[0].Value;
            Console.WriteLine("The rows count is : {0}", rowsCount);

I've attached the live example which demonstrates this approach.

Sergey Abakumoff
GrapeCity
   Report 
   01-20-2010, 11:25 PM
Sergey is not online. Last active: 3/3/2010 9:56:56 PM Sergey

Top 10 Posts
Joined on 08-28-2004
Novosibirsk, Russia
Posts 2,780

DDStaff
Re: How to open a report directly into excel format, without rendering/viewing it in reportviewer control?
I also entered the request about adding more comfortable way to check the data existence. The change request number is 141898.

Sergey Abakumoff
GrapeCity
   Report 
   01-21-2010, 10:06 AM
radhat is not online. Last active: 1/21/2010 3:56:09 AM radhat

Not Ranked
Joined on 07-24-2008
Posts 14
Re: How to open a report directly into excel format, without rendering/viewing it in reportviewer control?
I'm glad you caught that. I was on my way back here to report that I had found the same thing.
Let me start by saying thanks for working with me on this.
That being said. You're solution is functional given the right set of circumstances.
However, I cannot depend on the report writer to always put in a count parameter in his/her report(s). that would be modifying the report to fit the application, instead of vice versa.

This soltution would require all existing and future reports that I want to work with in this application have a count parameter in them and hidden or not that's a pain/overhead I'm not willing to subject either myself or my fellow report writers to.

If I've misread this please let me know.

Thanks again
   Report 
   01-21-2010, 10:10 AM
Sergey is not online. Last active: 3/3/2010 9:56:56 PM Sergey

Top 10 Posts
Joined on 08-28-2004
Novosibirsk, Russia
Posts 2,780

DDStaff
Re: How to open a report directly into excel format, without rendering/viewing it in reportviewer control?
Hello,
Thanks for the feedback.
Unfortunately there is no easy solution which allows to find out that there is no data returned by the report's dataset. But as I mentioned I entered the change request for that and we will  implement ReportRuntime.NoData event or something similar.

Sergey Abakumoff
GrapeCity
   Report 
GrapeCity » Product Support » Data Dynamics R... » How to open a report directly into excel format, without rendering/viewing it in reportviewer control?

Privacy Policy | Copyright © 1997-2010 - GrapeCity, inc.