VOOZH about

URL: https://www.cdata.com/kb/tech/excel-jdbc-datagrip.rst

⇱ Query Excel Data in DataGrip


Query Excel Data in DataGrip

πŸ‘ Jerod Johnson
Jerod Johnson
Director, Technology Evangelism
Create a Data Source for Excel in DataGrip and use SQL to query live Excel data.

DataGrip is a database IDE that allows SQL developers to query, create, and manage databases. When paired with the CData JDBC Driver for Microsoft Excel, DataGrip can work with live Excel data. This article shows how to establish a connection to Excel data in DataGrip and use the table editor to load Excel data.

Create a New Driver Definition for Excel

The steps below describe how to create a new Data Source in DataGrip for Excel.

  1. In DataGrip, click File -> New > Project and name the project πŸ‘ Creating a new DataGrip project.
  2. In the Database Explorer, click the plus icon () and select Driver. πŸ‘ Adding a new Driver.
  3. In the Driver tab:
    • Set Name to a user-friendly name (e.g. "CData Excel Driver")
    • Set Driver Files to the appropriate JAR file. To add the file, click the plus (), select "Add Files," navigate to the "lib" folder in the driver's installation directory and select the JAR file (e.g. cdata.jdbc.excel.jar).
    • Set Class to cdata.jdbc.excel.Excel.jar
  4. Click "Apply" then "OK" to save the Connection πŸ‘ A configured Driver (Salesforce is shown).

Configure a Connection to Excel

  1. Once the connection is saved, click the plus (), then "Data Source" then "CData Excel Driver" to create a new Excel Data Source.
  2. In the new window, configure the connection to Excel with a JDBC URL.

    Built-in Connection String Designer

    For assistance in constructing the JDBC URL, use the connection string designer built into the Excel JDBC Driver. Either double-click the JAR file or execute the jar file from the command-line.

     java -jar cdata.jdbc.excel.jar
     

    Fill in the connection properties and copy the connection string to the clipboard.

    Connecting to Local or Cloud-Stored (Box, Google Drive, Amazon S3, SharePoint) Excel Files

    CData Drivers let you work with Excel files stored locally and stored in cloud storage services like Box, Amazon S3, Google Drive, or SharePoint, right where they are.

    Setting connection properties for local files

    Set the URI property to local folder path.

    Setting connection properties for files stored in Amazon S3

    To connect to Excel file(s) within Amazon S3, set the URI property to the URI of the Bucket and Folder where the intended Excel files exist. In addition, at least set these properties:

    • AWSAccessKey: AWS Access Key (username)
    • AWSSecretKey: AWS Secret Key

    Setting connection properties for files stored in Box

    To connect to Excel file(s) within Box, set the URI property to the URI of the folder that includes the intended Excel file(s). Use the OAuth authentication method to connect to Box.

    Dropbox

    To connect to Excel file(s) within Dropbox, set the URI proprerty to the URI of the folder that includes the intended Excel file(s). Use the OAuth authentication method to connect to Dropbox. Either User Account or Service Account can be used to authenticate.

    SharePoint Online (SOAP)

    To connect to Excel file(s) within SharePoint with SOAP Schema, set the URI proprerty to the URI of the document library that includes the intended Excel file. Set User, Password, and StorageBaseURL.

    SharePoint Online REST

    To connect to Excel file(s) within SharePoint with REST Schema, set the URI proprerty to the URI of the document library that includes the intended Excel file. StorageBaseURL is optional. If not set, the driver will use the root drive. OAuth is used to authenticate.

    Google Drive

    To connect to Excel file(s) within Google Drive, set the URI property to the URI of the folder that includes the intended Excel file(s). Use the OAuth authentication method to connect and set InitiateOAuth to GETANDREFRESH.

    πŸ‘ Using the built-in connection string designer to generate a JDBC URL (Salesforce is shown.)
  3. Set URL to the connection string, e.g.,
    jdbc:excel:URI='C:/MyExcelWorkbooks/SampleWorkbook.xlsx';
  4. Click "Apply" and "OK" to save the connection string πŸ‘ A configured Data Source (Salesforce is shown).

At this point, you will see the data source in the Data Explorer.

Execute SQL Queries Against Excel

To browse through the Excel entities (available as tables) accessible through the JDBC Driver, expand the Data Source.

πŸ‘ Exploring the data (Salesforce is shown.)

To execute queries, right click on any table and select "New" -> "Query Console."

πŸ‘ Opening a new Query Console.

In the Console, write the SQL query you wish to execute. For example:

SELECT Name, Revenue FROM Sheet
πŸ‘ Querying with SQL (Salesforce is shown.)

Download a free, 30-day trial of the CData JDBC Driver for Microsoft Excel and start working with your live Excel data in DataGrip. Reach out to our Support Team if you have any questions.

Ready to get started?

Download a free trial of the Excel Driver to get started:

 Download Now

Learn more:

πŸ‘ Microsoft Excel Icon
Microsoft Excel JDBC Driver

Easily connect Java/J2EE applications with real-time data from Excel spreadsheets. Use Excel to manage the data that powers your applications.