Got a solution.
ApplicationClass excelApplication = null;
Workbook newWorkbook = null;
Worksheet targetSheet = null;
string paramWorkbookPath = Server.MapPath("~/Files/Template.xls");
string paramWorkbookPathNew = Server.MapPath("~/Files/" + System.Guid.NewGuid().ToString() + ".xls");
object paramMissing = Type.Missing;
excelApplication = new ApplicationClass();
newWorkbook = excelApplication.Workbooks.Open(paramWorkbookPath, 1,
false, paramMissing, paramMissing, paramMissing, false, paramMissing, paramMissing, false, true,
paramMissing, false, true, XlCorruptLoad.xlNormalLoad);
targetSheet = (Worksheet)(newWorkbook.Worksheets[1]);
targetSheet.get_Range("A7:E7", paramMissing).Value2 = "Srikanth";
targetSheet.get_Range("A8:C8", paramMissing).Value2 = "Not available";
newWorkbook.SaveAs(paramWorkbookPathNew, paramMissing, paramMissing, paramMissing, paramMissing,
paramMissing, XlSaveAsAccessMode.xlShared, paramMissing, paramMissing, paramMissing, paramMissing, paramMissing);
targetSheet = null;
if (newWorkbook != null)
{
newWorkbook.Close(false, paramMissing, paramMissing);
newWorkbook = null;
}
if (excelApplication != null)
{
excelApplication.Quit();
excelApplication = null;
}
GC.Collect();
GC.WaitForPendingFinalizers();
GC.Collect();
GC.WaitForPendingFinalizers();
Response.ClearContent();
Response.AddHeader("Content-Disposition", "attachment;filename = KPI.xls");
Response.ContentType = "application/vnd.ms-excel";
Response.TransmitFile(paramWorkbookPathNew);
Response.Flush();
System.IO.File.Delete(paramWorkbookPathNew);