exporting data to excel

Hello,
I am trying to export data from GridGrouping control to excel. while exporting I want my grid columns to be exported iin a paticular order while the order of columns in grid should not change.Is it possible?????
Or can i Export a datatable to excel ????
If both are not possible kindly suggest a way to overwrite data for a particu;ar column in the excel sheet created by exporting data from gridcontrol.Quick response will be highly Appreciated.

Thanks in advance
Ranju Malhotra


1 Reply

AD Administrator Syncfusion Team May 14, 2008 09:33 AM UTC

Hi Ranju,

You can a export a Datatable to the excel. Please refer the following code snippet that shows how we can export a Datatable to te Excel.


private void Export_Click(object sender, System.EventArgs e)
{
Syncfusion.GroupingGridExcelConverter.GroupingGridExcelConverterControl converter = new

Syncfusion.GroupingGridExcelConverter.GroupingGridExcelConverterControl();

SaveFileDialog saveFileDialog = new SaveFileDialog();
saveFileDialog.Filter = "Files(*.xls)|*.xls";
saveFileDialog.DefaultExt = ".xls";

if(saveFileDialog.ShowDialog() == DialogResult.OK)
{
if(radioButton1.Checked)
converter.GroupingGridToExcel(this.gridGroupingControl1, saveFileDialog.FileName,
Syncfusion.GridExcelConverter.ConverterOptions.Visible);
else if(radioButton2.Checked)
converter.GroupingGridToExcel(this.gridGroupingControl1,

saveFileDialog.FileName,
Syncfusion.GridExcelConverter.ConverterOptions.Default);

if(MessageBox.Show("Do you wish to open the xls file now?", "Export to Excel",

MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
{
Process proc = new Process();
proc.StartInfo.FileName = saveFileDialog.FileName;
proc.Start();
}
}
}


Please refer the following sample in the below link that illustrates the above.

http://websamples.syncfusion.com/samples/Grid.Windows/F73584/main.htm


You can also refer the GridExport sample :

\\Syncfusion\EssentialStudio\5.2.0.25\Windows\Grid.Grouping.Windows\Samples\2.0\Serialization\Excel Export\


Regards,
Asem.



Loader.
Up arrow icon