Use OpenRowSet to Operate Excel

Source: Internet
Author: User

There are two interfaces available: Microsoft. Jet. OLEDB.4.0 (hereinafter referred to as the Jet engine) and Microsoft. ACE. OLEDB.12.0 (hereinafter referred to as the ACE engine ).

You are familiar with the Jet engine and can access Office 97-2003, but cannot access Office 2007.

The ACE engine is a database connection component released along with Office 2007. It can access Office 2007 or Office 97-2003.

In addition, Microsoft. ACE. OLEDB.12.0 can access an Excel file that is being opened, but Microsoft. Jet. OLEDB.4.0 cannot.

 

Syntax example:

--> Access Excel 97-2003 with the Jet engine

  1. Select * from OpenRowSet ('Microsoft. jet. OLEDB.4.0 ', 'excel 8.0; HDR = Yes; IMEX = 1; Database = D: \ 97-2003.xls', 'select * from [Sheet1 $] ')
  2. Select * from OpenRowSet ('Microsoft. Jet. OLEDB.4.0 ', 'excel 8.0; HDR = Yes; IMEX = 1; Database = D: \ 97-2003.xls', [Sheet1 $])
  3. Select * from OpenDataSource ('Microsoft. Jet. OLEDB.4.0 ', 'excel 8.0; HDR = Yes; IMEX = 1; Database = D: \ 97-2003.xls')... [Sheet1 $]
  4. Select * from OpenDataSource ('Microsoft. jet. OLEDB.4.0 ', 'Data Source = D: \ 97-2003.xls; Extended Properties = "Excel 8.0; HDR = Yes; IMEX = 1 "')... [Sheet1 $]

 

--> ACE engine access Excel 97-2003

  1. Select * from OpenRowSet ('Microsoft. ACE. OLEDB.12.0 ', 'excel 12.0; HDR = Yes; IMEX = 1; Database = D: \ 97-2003.xls', 'select * from [Sheet1 $] ')
  2. Select * from OpenRowSet ('Microsoft. ACE. OLEDB.12.0 ', 'excel 12.0; HDR = Yes; IMEX = 1; Database = D: \ 97-2003.xls', [Sheet1 $])
  3. Select * from OpenDataSource ('Microsoft. ACE. OLEDB.12.0 ', 'excel 12.0; HDR = Yes; IMEX = 1; Database = D: \ 97-2003.xls')... [Sheet1 $]
  4. Select * from OpenDataSource ('Microsoft. ACE. OLEDB.12.0 ', 'Data Source = D: \ 97-2003.xls; Extended Properties = "Excel 12.0; HDR = Yes; IMEX = 1 "')... [Sheet1 $]

--> ACE engine access Excel 2007

  1. Select * from OpenRowSet ('Microsoft. ACE. OLEDB.12.0 ', 'excel 12.0; HDR = Yes; IMEX = 1; Database = D: \ 2007.xlsx', 'select * from [Sheet1 $] ')
  2. Select * from OpenRowSet ('Microsoft. ACE. OLEDB.12.0 ', 'excel 12.0; HDR = Yes; IMEX = 1; Database = D: \ 2007.xlsx', [Sheet1 $])
  3. Select * from OpenDataSource ('Microsoft. ACE. OLEDB.12.0 ', 'excel 12.0; HDR = Yes; IMEX = 1; Database = D: \ 2007.xlsx')... [Sheet1 $]
  4. Select * from OpenDataSource ('Microsoft. ACE. OLEDB.12.0 ', 'Data Source = D: \ 2007.xlsx; Extended Properties = "Excel 12.0; HDR = Yes; IMEX = 1 "')... [Sheet1 $]

Note:

Excel 2007 workbook File Extension: xlsx

HDR = Yes/No

Optional. specifies whether the column name is in the first row of the Excel table. The default value is Yes. You can modify the default behavior in the registry.

IMEX = 1

(Optional) parses a mix of Intermixed Data Types in an Excel table into text.

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.