We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy.
Unfortunately, activation email could not send to your email. Please try again.

convert to excel a selectrecords

Thread ID:

Created:

Updated:

Platform:

Replies:

98101 Feb 4,2011 05:52 AM Feb 9,2011 11:22 PM ASP.NET Web Forms (Classic) 1
loading
Tags: XlsIO
alvin
Asked On February 4, 2011 05:52 AM

hi,
i'm new on syncfusion and i search convert to excel : selectedrecords from gridgrouping control.

Thanks for help in advance :)


Mahendran [Syncfusion]
Replied On February 9, 2011 11:22 PM

Hi Alvin,

Thanks for your interest in Syncfusion Products.

In GridGroupingControl to convert the selected records to excel you need handle the ExportElement event handler with respective code. We have created a sample and attached below for your reference in which this requirement has been achieved.

Code snippet [C #]


private void button1_Click(object sender, EventArgs e)
{
if (this.gridGroupingControl1.Table.SelectedRecords.Count > 0)
{
ExcelEngine xl = new ExcelEngine();
IApplication app = xl.Excel;
app.DefaultVersion = ExcelVersion.Excel2010 ;
IWorkbook workBook = app.Workbooks.Create();
IWorksheet sheet = workBook.Worksheets[0];
GroupingGridExcelConverterControl converter = new GroupingGridExcelConverterControl();
converter.ExportElement += new GroupingGridExcelConverterControl.GridExportElementEventHandler(converter_ExportElement);
converter.GroupingGridToExcel(this.gridGroupingControl1 ,sheet, Syncfusion.GridExcelConverter.ConverterOptions.Default);
workBook.SaveAs("Test.xlsx");
}
}

void converter_ExportElement(object sender, GridExportElementEventArgs e)
{
if (e.Element.Kind == DisplayElementKind.Record && !this.gridGroupingControl1.Table.SelectedRecords.Contains(e.Element.GetRecord()))
{
e.Cancel = true;
}
}


Here is a sample for your reference

http://www.syncfusion.com/uploads/redirect.aspx?&team=support&file=SampleForExcel787466356.zip

Please let me know if you have any concerns.

Regards,
R.Mahendran



CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.

;