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: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Export to Excel Template

Thread ID:





120260 Sep 15,2015 08:21 AM UTC Oct 2,2015 12:12 PM UTC WinForms 3
Tags: GridGroupingControl
Dani Silva
Asked On September 15, 2015 08:21 AM UTC

There is any way to export a datagrid to an Excel template?
Something like:
Dim converter As GroupingGridExcelConverterControl = New GroupingGridExcelConverterControl
converter.GroupingGridToExcel(Me.grdPreview, "Grid.xls", ConverterOptions.Visible)
But to an existing template Excel file, not to a new one.

Adhikesevan Kothandaraman [Syncfusion]
Replied On September 16, 2015 12:21 PM UTC

Hi Daniel,

Thanks for contacting Syncfusion Support.

The reported scenario can be achieved by using simple workaround. We must create a worksheet to convert the grid to excel and then move the used range of exported worksheet to the already existing worksheet. Please refer to the following code example,

Code Example:

GroupingGridExcelConverterControl converter = new GroupingGridExcelConverterControl();           

ExcelEngine excelEngine = new ExcelEngine();

OpenFileDialog openFileDialog = new OpenFileDialog();

openFileDialog.Filter = "Files(*.xls)|*.xlx";

openFileDialog.DefaultExt = ".xls";           

if (openFileDialog.ShowDialog() == DialogResult.OK)


    //Create the object for the WorkBook

    IWorkbook sourceWorkBook = excelEngine.Excel.Workbooks.Open(openFileDialog.FileName);

    //Create temp worksheet for converting the grid to excel.


    //Export grid to the temp worksheet

    converter.GroupingGridToExcel(this.gridGroupingControl1, sourceWorkBook.Worksheets["Dummy"], Syncfusion.GridExcelConverter.ConverterOptions.Default);

   //Get the used range of temp worksheet

    IRange currenRange = sourceWorkBook.Worksheets["Dummy"].UsedRange;  

    //get the used range of Primary worksheet

    IRange excelRange = sourceWorkBook.Worksheets[0].UsedRange;

    //Move the used range of temp worksheet to the end of the used range of primary worksheet


    //Remove the temp worksheet from the workbook.


    //Save the changes in the workbook


    if (MessageBox.Show("Do you wish to open the xls file now?", "Export to Excel", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)


        Process proc = new Process();

        proc.StartInfo.FileName = openFileDialog.FileName;






Dani Silva
Replied On October 1, 2015 10:51 AM UTC

Hi again,
Sorry for my late answer.
It's running, quickly and efficient.
Thank you very much :-)

Dani Silva

Anish George [Syncfusion]
Replied On October 2, 2015 12:12 PM UTC

 Hi Daniel,
Thanks for your update

Please let us know if need any assistance.


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.

Please sign in to access our forum

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

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