hi, i can export a values from gridview to an excel sheet and i am done with that, the problem what i have now is, i want to populate the values from grid view into already existing excel template (existing template already contains header, footer, column name and all ) please help me out wit code friends.
here i have my code which creates a new excel sheet, but i want to fill already existing excel sheet. this is my c# code.
protected void exporttoexcel_Click(object sender, EventArgs e)
{
Microsoft.Office.Interop.Excel.Application xla = new Microsoft.Office.Interop.Excel.Application();
Workbook vb = xla.Workbooks.Add(XlSheetType.xlWorksheet);
Worksheet ws = (Worksheet)xla.ActiveSheet;
xla.Visible = true;
ws.Cells[1,1]="Slno";
ws.Cells[1, 2] = "code";
ws.Cells[1, 3] = "name";
ws.Cells[1, 4] = "Ashte";
ws.Cells[2, 1] = TextBox1.Text;
ws.Cells[2, 2] = TextBox2.Text;
ws.Cells[2, 3] = TextBox3.Text;
ws.Cells[2, 4] = TextBox4.Text;
ws.Cells[11, 9] = TextBox4.Text;
}