Click here to Skip to main content
16,012,316 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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;

}
Posted
Updated 13-Jan-12 19:54pm
v2

1 solution

 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900