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.
<