This article uses the CData ODBC driver for REST to import data in Excel with Microsoft Query. This article also demonstrates how to use parameters with Microsoft Query.
The CData ODBC driver for REST uses the standard ODBC interface to link REST data with applications like Microsoft Access and Excel. Follow the steps below to use Microsoft Query to import REST data into a spreadsheet and provide values to a parameterized query from cells in a spreadsheet.
If you have not already, first specify connection properties in an ODBC DSN (data source name). This is the last step of the driver installation. You can use the Microsoft ODBC Data Source Administrator to create and configure ODBC DSNs.
See the Getting Started chapter in the data provider documentation to authenticate to your data source: The data provider models REST APIs as bidirectional database tables and XML/JSON files as read-only views (local files, files stored on popular cloud services, and FTP servers). The major authentication schemes are supported, including HTTP Basic, Digest, NTLM, OAuth, and FTP. See the Getting Started chapter in the data provider documentation for authentication guides.
After setting the URI and providing any authentication values, set Format to "XML" or "JSON" and set DataModel to more closely match the data representation to the structure of your data.
The DataModel property is the controlling property over how your data is represented into tables and toggles the following basic configurations.
- Document (default): Model a top-level, document view of your REST data. The data provider returns nested elements as aggregates of data.
- FlattenedDocuments: Implicitly join nested documents and their parents into a single table.
- Relational: Return individual, related tables from hierarchical data. The tables contain a primary key and a foreign key that links to the parent document.
See the Modeling REST Data chapter for more information on configuring the relational representation. You will also find the sample data used in the following examples. The data includes entries for people, the cars they own, and various maintenance services performed on those cars.
You can then work with live REST data in Excel.
NOTE: In recent versions of Excel, Microsoft Query is not visible by default. To enable visibility, Navigate to Options > Data and check From Microsoft Query (Legacy) under the Show legacy data import wizards section.
- In Excel, open the Data tab and choose Get Data -> Legacy Wizards -> From Microsoft Query (Legacy).
- Choose the REST DSN. Select the option to use Query Wizard to create/edit queries.
- In the Query Wizard, expand the node for the table you would like to import into your spreadsheet. Select the columns you want to import and click the arrow to add them to your query. Alternatively, select the table name to add all columns for that table.
- The Filter Data page allows you to specify criteria. For example, you can limit results by setting a date range.
- If you want to use parameters in your query, select the option to edit the query in Microsoft Query.
To set a parameter in the query, you will need to modify the SQL statement directly. To do this, click the SQL button in the Query Editor. If you set filter criteria earlier, you should have a WHERE clause already in the query.
To use a parameter, use a "?" character as the wildcard character for a field's value in the WHERE clause. For example, if you are importing the people, you can set "[ personal.name.last ]=?".
- Close the SQL dialog when you are finished editing the SQL statement. You will be prompted to enter a parameter value. In the next step, you will select a cell to provide this value. So, leave the box in the dialog blank.
-
Click File -> Return Data to Microsoft Excel. The Import Data dialog is displayed. Enter a cell where results should be imported.
- Close the Import Data dialog. You will be prompted to enter a parameter value. Click the button next to the parameter box to select a cell. Select the option to automatically refresh the spreadsheet when the value changes.
The data is now imported into Excel. When you change the value in cell B1, the data will be filtered by the specified search criteria.
FAQs
How do I create a data connection in Excel?
- Open an Excel workbook and go to Data > Get Data. ...
- From the drop-down menu, select the source you would like to connect to. ...
- From the “Import Data” dialog box, select the Access file to import.
Can Excel connect to a rest API? ›
A REST API for Excel Services enables operations against Excel workbooks by using operations specified in the HTTP standard. This allows for a flexible, secure, and simpler mechanism to access and manipulate Excel Services content.
How do you reset data connections in Excel? ›
In the Connections group, select Connections > select the connection > Properties. Select the Usage tab and then select Refresh data when opening the file.
How do I connect access Data to Excel? ›
If you're using the latest version of the Microsoft 365 , Access 2021, or Access 2019, on the External Data tab, in the Import & Link group, click New Data Source > From File > Excel. If you're using Access 2016, on the External Data tab, in the Import & Link group, click Excel.
How do I open Data in Excel? ›
Import Data
- Click the Data tab on the Ribbon..
- Click the Get Data button. Some data sources may require special security access, and the connection process can often be very complex. ...
- Select From File.
- Select From Text/CSV. ...
- Select the file you want to import.
- Click Import. ...
- Verify the preview looks correct. ...
- Click Load.
How to pull API data to Excel? ›
How to extract the API data in an Excel sheet
- Step 1: retrieve the API data URL.
- Step 2: create a new, blank Excel document.
- Step 3: paste the API data URL in the Excel document.
- Step 4: Enter the credentials.
- Step 5: load the API data in the Excel.
How do I connect to API rest? ›
Step #1 – Open your testing tool of choice. Step #2 – Enter the sample REST API URL in the URL textbox of the tool. Step #3 – Select the HTTP method used for this particular API—GET, POST, PUT, PATCH, or DELETE. Step #4 – If required, enter any headers in the Headers textbox.
How to extract data from rest API? ›
To fetch data from a REST API using an ETL tool, you'll first establish a connection to the API endpoint. Then, define parameters like authentication credentials and data format. Configure the tool to retrieve data either at scheduled intervals or on-demand.
What is the difference between query and connection in Excel? ›
The role of the query is to shape the data. The role of the connection information is to maintain data source information and to refresh the data according to refresh settings, such as the frequency. Not all queries may be loaded to a worksheet.
How to source data in Excel? ›
From Table/Range
- Select any cell within your data range.
- Select Data > From Table/Range. ...
- If prompted, in the Create Table dialog box, you can select the Range Selection button to select a specific range to use as a data source.
- If the table or range of data has column headers, select My table has headers. ...
- Select OK.
Go to Data > Consolidate. In the Function box, select the function that you want Excel to use to consolidate the data. To indicate where the labels are located in the source ranges, select the check boxes under Use labels in: either the Top row, the Left column, or both. In each source sheet, select your data.
How do I Connect to a CSV data source in Excel? ›
On the Data tab, in the Get & Transform Data group, click From Text/CSV. In the Import Data dialog box, locate and double-click the text file that you want to import, and click Import. In the preview dialog box, you have several options: Select Load if you want to load the data directly to a new worksheet.
How to find data connections in Excel? ›
In Excel, click Data > Connections. Select the connection used to populate the table in your model. Click Properties > Definition to view the connection string.
How do I Connect missing data in Excel? ›
Go to Chart Tools on the Ribbon, then on the Design tab, in the Data group, click Select Data. Click Hidden and Empty Cells. In the Show empty cells as: options box, click Gaps, Zero, or Connect data points with line.
How do I see all Data connections in Excel? ›
Manage connections by using the Queries & Connections pane
The Queries & Connections pane (Select Data > Queries & Connections) In one location, you can get to all the information and commands you need to work with your external data. This pane has two tabs: Queries Displays all the queries in the workbook.
How do I enable all Data connections in Excel? ›
Click Options > Trust Center > Trust Center Settings. On the left, select External Content. Click the option that you want under Security settings for Linked Data Types: Enable all Linked Data Types (not recommended): Click this option if you want to create linked data types without receiving a security warning.
How do I open Data connection wizard in Excel? ›
Open Excel. Click the Data tab. Click From Other Sources > From Analysis Services. The Data Connection Wizard is displayed.