I am fairly new to programming and GemBox. I found this code that inserts a data from a DataGridView to an existing Excel sheet with headers and footers. What happens with the code is it replaces the exisiting excel file totally and removes all the headers and footers. What I want to do is just insert the data starting from cell A:9 without removing the pre-existing data from other excel cells. Is there anyway to do this using GemBox?
private void replace_Click(object sender, EventArgs e)
{
var saveFileDialog = new SaveFileDialog();
saveFileDialog.Filter = "XLSX files (*.xlsx)|*.xlsx";
saveFileDialog.FilterIndex = 3;
if (saveFileDialog.ShowDialog() == DialogResult.OK)
{
var workbook = new ExcelFile();
var worksheet = workbook.Worksheets.Add("Sheet1");
var options = new ImportFromDataGridViewOptions();
options.ColumnHeaders = false;
options.StartRow = 8;
options.StartColumn = 0;
DataGridViewConverter.ImportFromDataGridView(worksheet, this.dataGridView1, options);
workbook.Save(saveFileDialog.FileName);
}
}
Any help would greatly be appreciated.