1 protectedApplication Objexcelapp;//defining an Excel Application Object2 PrivateWorkbooks Objexcelworkbooks;//Defining Workbook Workbook Collection Objects3 protectedWorkbook Objexcelworkbook;//define Excel Workbook Workbook objects4 PrivateWorksheet Objexcelworksheet;//Defining Workbook Sheet Objects5 6 7 8 9try{Ten stringWorktmp = Server.MapPath ("~/bjyh2014/quarterreportexcel.xlsx"); OneObjexcelapp =NewApplicationClass (); AObjexcelworkbooks =Objexcelapp.workbooks; -Objexcelworkbook =Objexcelworkbooks.open (worktmp, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing); - the -Objexcelworksheet = (Worksheet) objexcelworkbook.worksheets[1];//strSheetName refers to the sheet name of the Exce workbook, or "1" if it is not named - -objexcelworksheet.cells[ -,2] =" -";//IntRow, line, Intcol, strvalue, value after you finish processing +objexcelworksheet.cells[ -,3] =" $";//IntRow, line, Intcol, strvalue, value after you finish processing -objexcelworksheet.cells[ -,4] =" -";//IntRow, line, Intcol, strvalue, value after you finish processing +objexcelworksheet.cells[ -,5] =" -";//IntRow, line, Intcol, strvalue, value after you finish processing Aobjexcelworksheet.cells[ -,6] =" -";//IntRow, line, Intcol, strvalue, value after you finish processing at //object missing = System.Reflection.Missing.Value; - stringFileName =string. Format (Server.MapPath ("~/bjyh2014/excel/"+ session["Deptname"]. ToString () +"hidden Trouble Troubleshooting statistics {0}.XLSX"), now. ToString ("Yyyy-mm-dd-hh-mm-ss")); - - - Objexcelworkbook.saveas (FileName, Type.Missing, Type.Missing, Type.Missing, Type.Missing, TYPE.MI Ssing, Xlsaveasaccessmode.xlnochange, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing); - } in finally - { to objexcelapp.quit (); +}
C # Read Excel template Modify the value of a column in a row save as a new Excel