C # open an existing Excel File

Source: Internet
Author: User
1 Microsoft. office. interop. excel. application excelApp = new Microsoft. office. interop. excel. application (); 2 excelApp. visible = true; 3 // get the WorkBook object and open the existing file 4 Microsoft. office. interop. excel. workbook excelBook = excelApp. workbooks. _ Open (@ "e: \ excel.xls"); 5 // specify the Sheet 6 Microsoft. office. interop. excel. worksheet excelSheet = (Microsoft. office. interop. excel. worksheet) excelApp. activeSheet; 7 8 // you can add operations on files 9 10 excelSheet = null; 11 excelBook = null; 12 excelSheet = null; 13 excelBook = null; 14 // This sentence is very important, otherwise the Excel object cannot be interpreted from the memory 15 // if you just open the file and wait for the user to operate the Excel file, you can remove it, allow users to automatically release Excel Object Memory 16 excelBook when they close the file. quit (); 17 excelBook = null;

References: C # Excel operations (1)

Related Article

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.