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

Export to Excel Template

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.

3 Replies

AK Adhikesevan Kothandaraman Syncfusion Team 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;






DS Dani Silva 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

AG Anish George Syncfusion Team October 2, 2015 12:12 PM UTC

 Hi Daniel,
Thanks for your update

Please let us know if need any assistance.

Live Chat Icon For mobile
Up arrow icon