You can access data in Microsoft Excel worksheets by using either
the Excel wrapper or the ODBC wrapper.
To query Excel data, both wrappers require a federated server
that can open and read the worksheets in the Excel workbook. Therefore, the
Excel workbook must be on the same computer as the federated server or on
a network accessible drive.
If you use the Excel wrapper, the Excel
application must be installed on the federated server.
If you use the
ODBC wrapper, the Excel ODBC driver must be on the federated server. This
driver is installed automatically with Microsoft Windows®. The Excel application
does not need to be installed on the federated server.
Each wrapper
imposes some requirements on the location and layout of the data in the Excel
workbooks. With the Excel wrapper, only the data in the first worksheet in
the workbook can be accessed. With the ODBC wrapper, you can access data from
any worksheet in the workbook.
The following examples show the worksheet
layout requirements for these two wrappers.
Example of a worksheet that contains rows of labels and a
formula
This example shows a worksheet that contains several rows
of labels at the top of the worksheet, blank rows, and a formula in row 13.
To access the data in the worksheet, you must identify the range of cells
that you want to access.
Figure 1. A worksheet
that contains several rows of labels and a formula
- If you use the Excel wrapper
- You specify the range of cells in the CREATE NICKNAME statement by using
the RANGE option. Include only the data in the range that you specify. Do
not include any column labels in the range. Cells that contain formulas, such
as SUM, return the result of the formula and not the formula. Unless you want
the formula results returned, do not include the cells that contain formulas
in the range. In this example, the range of cells that you include in the
RANGE option is A4:D11.
- If you use the ODBC wrapper
- You must create a name for the range of cells to explicitly designate
the location of the data within the worksheet. Excel refers to this range
of cells as a named range. The Excel ODBC driver recognizes only
one row of labels, the first row in the range. No blank rows are allowed between
the labels and the data. The named range must include only one row of column
labels. You specify the named range in the CREATE NICKNAME statement. You
must include one row of column labels in the range that you name. If you do
not include one row of column labels in the named range, the first row of
data is treated as column labels. Cells that contain formulas, such as SUM,
return the result of the formula and not the formula. Unless you want the
formula results returned, do not include the cells that contain formulas in
the range. In this example, the range of cells that you name is A3:D11.
Example of a worksheet that contains one row of labels
This
example shows a worksheet that contains only one row of column labels at the
top of the worksheet. The layout does not include extra rows with labels,
blank rows, or cells with formulas.
Figure 2. A
worksheet that contains one row of column labels in row 1
- If you use the Excel wrapper
- You must specify the range of cells in the CREATE NICKNAME statement by
using the RANGE option. The range cannot include the column labels in row
1. The range of cells that you would specify is A2:D9.
- If you use the ODBC wrapper
- You can access this data without creating a named range. You specify
the worksheet name in the CREATE NICKNAME statement. The wrapper reads the
first nonblank row as labels and uses the information as column names for
the nickname. Subsequent rows are read as data.
Example of a worksheet that contains only data
This
example shows a worksheet that contains only data. There are no rows of column
labels, no blank rows, and no cells with formulas.
Figure 3. A worksheet that contains only data
- If you use the Excel wrapper
- If the data is in the first worksheet in the workbook, the wrapper will
access the data without using the RANGE option. If the data is in another
worksheet in the workbook, you must specify the RANGE option in the CREATE
NICKNAME statement.
- If you use the ODBC wrapper
- When you use the ODBC wrapper to access Excel data, the wrapper is limited
by what the Excel ODBC driver supports. The Excel ODBC driver requires a specific
format for the worksheet. The driver assumes that the first nonblank row contains
the column labels. If the first nonblank row contains data, the data in that
row is treated as the column labels for the remaining data. If the worksheet
does not contain a row of column labels, the first row is used as the labels
and not as data. In effect, you lose the first row of data. You can overcome
this requirement by modifying your worksheet. Insert a new row before the
data and add labels for each column of data, so that it looks like the example
that contains one row of labels.