Read data from EXCEL files in C #. net

Source: Internet
Author: User

The method for reading data from an EXCEL table is similar to ACCESS. EXCEL is just a different form of database.

In the. cs file, first reference OLEDB: using System. Data. OleDb;

The method for accessing the access database is: "Provider = Microsoft. jet. oledb.4.0; data source = FilePath. mdb ;"

The access to EXCEL is similar, but the driver is different: "Provider = Microsoft. jet. OLEDB.4.0; "+" Data Source = "+" d: \ FIlePath.xls; "+" Extended Properties = Excel 8.0 ;";

Now that we have connected to excel, how can we get the value of the sheet table in it? In the sheet table, the default name of the first behavior field is used, and the value of the corresponding field is displayed in the second row and below ,. We recommend that you use [sheet1 $] As the table name during select. For example, select * from [sheet1 $]

The other values are the same as those of ACCESS. You only need to set them in ACCESS mode.

I hope these tips will help you.



<

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.