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. Image for the cookie policy date

How to use GroupingGridExcelConverterControl to export data as .xlsx format?

Hi Team,
 
Below code is ok for saving as .xls fileformat however it failed when I saved it as .xlsx. Could you give suggestions how to export data as .xlsx file format?
 
// my grid
private GridGroupingControl _gridGroupingControl1;
// save to .xls
using (GroupingGridExcelConverterControl converter = new GroupingGridExcelConverterControl()) 
      converter.GroupingGridToExcel(_gridGroupingControl1, @"D:\export.xls", ConverterOptions.Default);
 
Thanks,
Wuyj

1 Reply

NK Neelakandan Kannan Syncfusion Team January 2, 2015 04:57 AM UTC

Hi Wuyj,

Thank you for your interest in Syncfusion products.

If you want to save the GridGroupingControl exported excel file as .XLSX, you can specify the Worksheet version and excel engine version as 2013. Please make use of below code,

Code Snippet:

private void button1_Click(object sender, EventArgs e)

{

GroupingGridExcelConverterControl converter = new GroupingGridExcelConverterControl();

ExcelEngine excelEngine = new ExcelEngine();

IApplication application = excelEngine.Excel;

application.DefaultVersion = ExcelVersion.Excel2013;

IWorkbook chartBook = ExcelUtils.CreateWorkbook(1);

chartBook.Version = ExcelVersion.Excel2013;

IWorksheet sheet = chartBook.Worksheets[0];

converter.GroupingGridToExcel(this.gridGroupingControl1,sheet, ConverterOptions.Default);

chartBook.SaveAs("sample.xlsx");

Process.Start("sample.xlsx");

}

Sample:

http://www.syncfusion.com/downloads/support/directtrac/117867/Sample_Exporting95361951.zip

Please let me know if you have any concerns.

Regards,

Neelakandan



Loader.
Live Chat Icon For mobile
Up arrow icon