Excel Spreadsheet Automation with the QUERY Formula



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

The CData Excel Add-In for SharePoint provides formulas that can edit, save, and delete SharePoint data. The following three steps show how you can automate the following task: Search SharePoint data for a user-specified value and then organize the results into an Excel spreadsheet.

About SharePoint Data Integration

Accessing and integrating live data from SharePoint has never been easier with CData. Customers rely on CData connectivity to:

  • Access data from a wide range of SharePoint versions, including Windows SharePoint Services 3.0, Microsoft Office SharePoint Server 2007 and above, and SharePoint Online.
  • Access all of SharePoint thanks to support for Hidden and Lookup columns.
  • Recursively scan folders to create a relational model of all SharePoint data.
  • Use SQL stored procedures to upload and download documents and attachments.

Most customers rely on CData solutions to integrate SharePoint data into their database or data warehouse, while others integrate their SharePoint data with preferred data tools, like Power BI, Tableau, or Excel.

For more information on how customers are solving problems with CData's SharePoint solutions, refer to our blog: Drivers in Focus: Collaboration Tools.


Getting Started


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

This formula requires three inputs:

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

    Set the URL property to the base SharePoint site or to a sub-site. This allows you to query any lists and other SharePoint entities defined for the site or sub-site.

    The User and Password properties, under the Authentication section, must be set to valid SharePoint user credentials when using SharePoint On-Premise.

    If you are connecting to SharePoint Online, set the SharePointEdition to SHAREPOINTONLINE along with the User and Password connection string properties. For more details on connecting to SharePoint Online, see the "Getting Started" chapter of the help documentation

  • 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 SharePoint data, such as Location.
  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 MyCustomList WHERE Location = '"&B6&"'","User="&B1&";Password="&B2&";Auth Scheme="&B3&";URL="&B4&";SharePointEdition="&B5&";Provider=SharePoint",B7)
  4. Change the filter to change the data.

Ready to get started?

Download a free trial of the Excel Add-In for SharePoint to get started:

 Download Now

Learn more:

SharePoint Icon Excel Add-In for SharePoint

The SharePoint Excel Add-In is a powerful tool that allows you to connect with live data from SharePoint and SharePoint Online, directly from Microsoft Excel.

Use Excel to read, write, and update SharePoint Lists, Contacts, Calendar, Links, Tasks, etc. Perfect for mass imports / exports / updates, data cleansing & de-duplication, Excel based data analysis, and more!