)
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 save the WinForms GridControl with changed values to an excel sheet?

Platform: WinForms |
Control: GridControl |
Published Date: May 18, 2016 |
Last Revised Date: December 16, 2019
Tags: exporting

Save the grid

In order to save the grid control with changed values, we have to save the Workbook after exporting the grid to excel. IWorkBook.Save() method can be used to save the changed values in spread sheet.

C#

private void btnExport_Click(object sender, EventArgs e)
{
   ExcelEngine engine = new ExcelEngine();
   IApplication app = engine.Excel.Application;
   app.DefaultVersion = ExcelVersion.Excel2010;
   IWorkbook workBook = app.Workbooks.Create();
   workBook = engine.Excel.Workbooks.Open(@"..\..\Book1.xlsx");
   IWorksheet sheet = workBook.Worksheets[0];
   control.GridToExcel(this.gridControl1, sheet, ConverterOptions.Default);
   //Save the workbook.
   workBook.Save();
   Process.Start(@"..\..\Book1.xlsx");
}

 

VB

Private Sub btnExport_Click(ByVal sender As Object, ByVal e As EventArgs)
   Dim engine As New ExcelEngine()
   Dim app As IApplication = engine.Excel.Application
   app.DefaultVersion = ExcelVersion.Excel2010
   Dim workBook As IWorkbook = app.Workbooks.Create()
   workBook = engine.Excel.Workbooks.Open("..\..\Book1.xlsx")
   Dim sheet As IWorksheet = workBook.Worksheets(0)
   control.GridToExcel(Me.gridControl1, sheet, ConverterOptions.Default)
   'Save the workbook.
   workBook.Save()
   Process.Start("..\..\Book1.xlsx")
End Sub

 

Samples:

C#: SaveChangesToExcel_CS

VB: SaveChangesToExcel_VB

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

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