Microsoft Access OLE DB — Microsoft Excel

From database24
Revision as of 15:57, 8 November 2016 by Dec (talk | contribs) (Initial)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Microsoft Excel

Every worksheet or (named) range is considered as table when accessing Microsoft Excel files.

SELECT *
  FROM [...] 
    IN 'c:\source.xls'[EXCEL 8.0;];


Named Range

Accessing data by naming ranges allows the developer to specify exactly what should be imported. By this—and the optional parameters—it should be easy to retrieve exactly the desired data and nothing else.

SELECT *
  FROM [NamedRange] 
    IN 'c:\source.xls'[EXCEL 8.0;];

Worksheet

The selection of worksheets is usually not recommended, as the selection will also contain empty cells and maybe other unwanted content.

SELECT *
  FROM [Worksheet$] 
    IN 'c:\source.xls'[EXCEL 8.0;];

Reference

In rare cases it is necessary to retrieve the content of a certain cell range.

SELECT *
  FROM [Worksheet$A1:B2] 
    IN 'c:\source.xls'[EXCEL 8.0;];

Optional Parameters

HDR
The header parameter specifies, whether the first row should be interpreted as column headers.
Possible values: HDR=yes, HDR=no
IMEX
In order to identify the content of a column usually the first eight rows are scanned for values and the rest of the column is identified accordingly.
Unfortunately this behaviour often leads to misinterpretation and error values.
Setting this parameter to 0 suppresses the value type interpretation and enforces the data type "text" for all columns.
Possible values: IMEX=0