C # Operations Excel file ~ Action on an existing Excel file

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.