)
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. (Last updated on: June 24, 2019).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

How to export the grid to particular worksheet of existing workbook in WinForms GridControl?

Platform: WinForms |
Control: GridControl |
Published Date: August 8, 2016 |
Last Revised Date: December 16, 2019

Excel Export

The GridControl provides support to export the grid to specified worksheet in an existing workbook by passing that worksheet as parameter in the GridToExcel method like below.

Code Snippet

C#

ExcelEngine engine = new ExcelEngine();
IApplication app = engine.Excel.Application;
app.DefaultVersion = ExcelVersion.Excel2013;
IWorkbook workBook = app.Workbooks.Create();
workBook = engine.Excel.Workbooks.Open("..\\..\\Sample.xlsx");
workBook.Version = ExcelVersion.Excel2013;
IWorksheet sheet = workBook.Worksheets["B"];
converter.GridToExcel(this.gridControl1, sheet, ConverterOptions.Visible);
workBook.Save();
Process.Start("..\\..\\Sample.Xlsx");

 

VB

Dim engine As New ExcelEngine()
Dim app As IApplication = engine.Excel.Application
app.DefaultVersion = ExcelVersion.Excel2013
Dim workBook As IWorkbook = app.Workbooks.Create()
workBook = engine.Excel.Workbooks.Open("..\..\Sample.xlsx")
workBook.Version = ExcelVersion.Excel2013
Dim sheet As IWorksheet = workBook.Worksheets("B")
converter.GridToExcel(Me.gridControl1, sheet, ConverterOptions.Visible)
workBook.Save()
Process.Start("..\..\Sample.Xlsx")

 

Samples:

C#: Export_to_WorkSheet_CS

VB: Export_to_WorkSheet_VB

Reference link: https://help.syncfusion.com/windowsforms/grid-control/exporting

2X faster development

The ultimate WinForms UI toolkit to boost your development speed.
ADD COMMENT
You must log in to leave a comment

Please sign in to access our KB

This page will automatically be redirected to the sign-in page in 10 seconds.

Up arrow icon

Warning Icon 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.Close Icon

Live Chat Icon For mobile
Live Chat Icon