Re: Export to Excel in C#
Data Dynamics Reports Support
Export to Excel in C#
03-07-2010, 10:27 PM
Hi,
I am using Data Dynamics Reports Version : 1.6.1588.0.
I am able to export the Report to excel through DataDynamics.
But i am not able to export the Reports to Excel through C#.
Is there a way to achieve this?
Do sent me some sample Reports for the above requirements.
Thanks
parthi
Re: Export to Excel in C#
03-08-2010, 6:29 AM
Parthi,
You may use following code snippet to render the report to excel via code:
//Load the RDLX in the Report Definition
DataDynamics.Reports.ReportDefinition _reportDef = new DataDynamics.Reports.ReportDefinition(new System.IO.FileInfo(Application.StartupPath + @"..\..\..\Report1.rdlx"));
//Load the Report Definition in the Report Runtime
DataDynamics.Reports.ReportRuntime _reportRuntime = new DataDynamics.Reports.ReportRuntime(_reportDef);
string exportFile = System.IO.Path.GetTempFileName() + ".xls";
//Create a new FileInfo object
System.IO.FileInfo myFile = new System.IO.FileInfo(exportFile);
//Create an onject of ExcelTransformationDevice
DataDynamics.Reports.Rendering.Excel.ExcelTransformationDevice _renderingExtension = new DataDynamics.Reports.Rendering.Excel.ExcelTransformationDevice();
//Create an object of FileStreamProvider
DataDynamics.Reports.Rendering.IO.FileStreamProvider _provider=new DataDynamics.Reports.Rendering.IO.FileStreamProvider(myFile.Directory, System.IO.Path.GetFileNameWithoutExtension(myFile.Name));
//Render the report to the ExcelTransformationDevice Object
_reportRuntime.Render(_renderingExtension, _provider);
//Open the rendered report in Excel
System.Diagnostics.Process.Start(exportFile);
Also find attached a sample application in which I have implemented the desired functionality.
Amit Pal
GrapeCity- DataDynamics