BoldSignEasily embed eSignatures in your .NET applications. Free sandbox with native SDK available.
Dim converter As GroupingGridExcelConverterControl = New GroupingGridExcelConverterControlconverter.GroupingGridToExcel(Me.grdPreview, "Grid.xls", ConverterOptions.Visible)
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.
sourceWorkBook.Worksheets.Create("Dummy");
//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
currenRange.MoveTo(sourceWorkBook.Worksheets[0][excelRange.Rows.Length+1,1]);
//Remove the temp worksheet from the workbook.
sourceWorkBook.Worksheets["Dummy"].Remove();
//Save the changes in the workbook
sourceWorkBook.Save();
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;
proc.Start();
}
}
Sample:
http://www.syncfusion.com/downloads/support/forum/120260/ze/ExportToExcelTemplate1032270483
Regards,
Adhi