I have a simple .NET datatable. I want to export the data to an excel. I would like to use an ultrawingrid to do the export.
Here is the code...
UltraGrid
ultradg = new UltraGrid();
ultradg.DataSource = table;
ultradg.DataBind();
UltraGridExcelExporter
ultraGridExcelExporter1= new UltraGridExcelExporter();
this.ultraGridExcelExporter1.Export(ultradg, path);
Seems simple enough..But it doesnt export any data..The datatable has got data...
Sorry... I think the code was not readable..Here is it again
UltraGrid ultradg = new UltraGrid();ultradg.DataSource = table; ultradg.DataBind();
UltraGridExcelExporter ultraGridExcelExporter1= new UltraGridExcelExporter();
Hi,
It's probably because the grid has no BindingContext. Since you are creating a grid in code and never parenting it to a form, it has no context for data binding.
Not parenting the grid to a form also means that it will never get disposed (unless you dispose it).
So it's generally good practice to add the grid to the Controls collection of a form. The form will dispose the grid when the form itself is disposed and this will provide a BindingContext.
Another option would be to simply set the grid.BindingContext to the form.BindingContext of any form you happen to have access to.
Or, as a last resort, you could simply set grid.BindingContext to a new BindingContext.
The excel export works for me as long as if give the path where to export.
But, What should I need to do if I need the exporter to just open the excel file and gives me an option to choose the folder to where I can save.
I tried ultraGridExcelExporter.Export(_grdToExport) and it didn't work. Any Idea?
Hello,
Could you please review the sample attached to this post and see if it meets your requirements.
Please feel free to let me know if I misunderstood you or if you have any other questions.
Yes.It worked.Thanks.
Thanks Kishor
Thanks dude... its worked for my issue.
Kishor Kodakkatil
Software Engineer