Articles in this section
Category / Section

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

1 min read

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

Did you find this information helpful?
Yes
No
Help us improve this page
Please provide feedback or comments
Comments (0)
Please sign in to leave a comment
Access denied
Access denied