If I want to achieve the purpose that I am manipulating the resulting data added in an existing Excel table think of a method with 2:
1. Copy all data delete table, new table, previous data + new data into
2. Idea of reading Excel table
Take Method 2:
Function Two: operation on an existing Excel file
The premise and the previous article are the same
<summary>////For existing Excel files///</summary> static void Modifyexcelfile () { An already existing Excel string Excelfilepath = "E:\\vs project path \ \ Test generates Excel2\\mytext.xls"; Initialize msexcel.application myexcel = new Msexcel.applicationclass (); object omissing = System.Reflection.Missing.Value; Read Excel template Msexcel.workbook MyBook = MyExcel.Application.Workbooks.Open (Excelfilepath, omissing, omissing, OMi Ssing, omissing, omissing, omissing, omissing, omissing, omissing, omissing, omissing, omissing, oMissing, oMissing); Use the first worksheet as the worksheet for inserting data msexcel.worksheet MySheet = (msexcel.worksheet) mybook.worksheets[1]; Assignment mysheet.cells[1, 1] = "Test"; Assigning a header to rows 5th and 5th in Excel is the 1th row//Assigning values to existing data overrides Mybook.close ( True, omissing, omissing); Save the modified Excel Myexcel.quit (); }
Notes: can generate Excel chart, PPT, interested can check their own
C # Operations Excel file ~ Action on an existing Excel file