Excel Spreadsheet Automation with the QUERY Formula



Pull data, automate spreadsheets, and more with the QUERY formula.

The CData Excel Add-In for Google Cloud Storage provides formulas that can query Google Cloud Storage data. The following three steps show how you can automate the following task: Search Google Cloud Storage data for a user-specified value and then organize the results into an Excel spreadsheet.

The syntax of the CDATAQUERY formula is the following: =CDATAQUERY(Query, [Connection], [Parameters], [ResultLocation]);

This formula requires three inputs:

  • Query: The declaration of the Google Cloud Storage data records you want to retrieve, written in standard SQL.
  • Connection: Either the connection name, such as GoogleCloudStorageConnection1, or a connection string. The connection string consists of the required properties for connecting to Google Cloud Storage data, separated by semicolons.

    Authenticate with a User Account

    You can connect without setting any connection properties for your user credentials. After setting InitiateOAuth to GETANDREFRESH, you are ready to connect.

    When you connect, the Google Cloud Storage OAuth endpoint opens in your default browser. Log in and grant permissions, then the OAuth process completes

    Authenticate with a Service Account

    Service accounts have silent authentication, without user authentication in the browser. You can also use a service account to delegate enterprise-wide access scopes.

    You need to create an OAuth application in this flow. See the Help documentation for more information. After setting the following connection properties, you are ready to connect:

    • InitiateOAuth: Set this to GETANDREFRESH.
    • OAuthJWTCertType: Set this to "PFXFILE".
    • OAuthJWTCert: Set this to the path to the .p12 file you generated.
    • OAuthJWTCertPassword: Set this to the password of the .p12 file.
    • OAuthJWTCertSubject: Set this to "*" to pick the first certificate in the certificate store.
    • OAuthJWTIssuer: In the service accounts section, click Manage Service Accounts and set this field to the email address displayed in the service account Id field.
    • OAuthJWTSubject: Set this to your enterprise Id if your subject type is set to "enterprise" or your app user Id if your subject type is set to "user".
    • ProjectId: Set this to the Id of the project you want to connect to.

    The OAuth flow for a service account then completes.

  • ResultLocation: The cell that the output of results should start from.

Pass Spreadsheet Cells as Inputs to the Query

The procedure below results in a spreadsheet that organizes all the formula inputs in the first column.

  1. Define cells for the formula inputs. In addition to the connection inputs, add another input to define a criterion for a filter to be used to search Google Cloud Storage data, such as Name.
  2. In another cell, write the formula, referencing the cell values from the user input cells defined above. Single quotes are used to enclose values such as addresses that may contain spaces.
  3. =CDATAQUERY("SELECT * FROM Buckets WHERE Name = '"&B2&"'","ProjectId="&B1&";Provider=GoogleCloudStorage",B3)
  4. Change the filter to change the data.

Ready to get started?

Download a free trial of the Excel Add-In for Google Cloud Storage to get started:

 Download Now

Learn more:

Google Cloud Storage Icon Excel Add-In for Google Cloud Storage

The Google Cloud Storage Excel Add-In is a powerful tool that allows you to connect with live Google Cloud Storage data, directly from Microsoft Excel.

Use Excel to access Google Cloud Storage Buckets, Objects, etc. Perfect for mass imports / exports / updates, data cleansing & de-duplication, Excel based data analysis, and more!