Wolfram Blog
Anthony Zupnik

Advanced Computation for Spreadsheets: Wolfram CloudConnector for Excel

November 5, 2019 — Anthony Zupnik, Kernel Developer, Compiler Development

Advanced Computation for Spreadsheets: Wolfram CloudConnector for Excel

Microsoft Excel is among the most popular tools in the world. For non-technical and advanced users aspiring to extend beyond Excel’s built-in feature set, we’re proud to announce the easiest and most productive tool for doing so: Wolfram CloudConnector for Excel, now available to anyone running Excel on a Windows system. You can access the advanced computational power of the Wolfram Language for your data directly from your spreadsheets.

Simple Function Calls

We’ve made it easy for anyone to start using CloudConnector for Excel using the Wolfram Excel function, which allows you to call native Wolfram Language code directly in an Excel cell. For example, CurrentDate in Excel will get you today’s date:



We can also add additional parameters to the Wolfram function. These values get slotted into the expression. RandomWord can take additional parameters, such as a number, which will generate that many words:



So in Excel, we can write:



Even though we have written this in a single Excel cell, the output fills out into a column.

Mixing Wolfram Language and Excel Code

CloudConnector automatically converts the Wolfram Language output to be displayed in Excel. If you wanted to get all the business days for the next 10 days, you would use the function DayRange:


DayRange[Now, DayPlus[Now, 10], "BusinessDay"]

Now let’s run this expression in a spreadsheet with the Wolfram function, applying quotes and escaped quotes as necessary. We add an “&” on the end to make the expression a pure function:

=Wolfram("DayRange[Now, DayPlus[Now, 10], ""BusinessDay""]&")

=Wolfram("DayRange[Now, DayPlus[Now, 10], ""BusinessDay""]&")

Notice how the dates are converted to an Excel format. This is an example of the automatic conversion from the Wolfram Language.

You can also pass data stored in a spreadsheet cell as an argument to this function:

=Wolfram("DayRange[Now, DayPlus[Now, #], ""BusinessDay""]&", B2)

=Wolfram("DayRange[Now, DayPlus[Now, #], ""BusinessDay""]&", B2)

Any update to the cell being used as an argument (in this case, B2) will trigger recalculation of the formula in Excel.

Centralize as an APIFunction

Often you will want to store the code outside the spreadsheet, either because you don’t want users to see or edit it, or because you want to be able to push centralized updates to many users simultaneously. Deploying the code as an API and then calling it from the spreadsheet addresses this need.

Converting the Wolfram Language code we had before into an APIFunction only requires some minor changes:


 APIFunction[{"x" -> "Integer"},
  DayRange[Now, DayPlus[Now, #x], "BusinessDay"] &,
  AllowedCloudExtraParameters -> All], "MyDayRangeFunction",
 Permissions -> "Public"]

There is one parameter, "x", that can take an integer. The APIFunction is deployed as a CloudObject with the name DayRange.

An Excel user can access this API with the WolframAPI function:



This formula evaluates entirely in the cloud. The source code is never seen by the caller of the API.

Advanced Computation, Minimal Code

With additional knowledge of the Wolfram Language, you can develop powerful Wolfram APIs, which would normally require a long and tedious development process in other systems.

Here, an APIFunction calculates the shortest tour of the 20 largest cities in a country and displays the result:


 APIFunction[{"Location" -> "Country"},
  Module[{cities, tour},
    cities = EntityClass[
     "City", {
      EntityProperty["City", "Country"] -> Entity[
        "Country", "Germany"],
       EntityProperty["City", "Population"] -> TakeLargest[20]}];
    tour = FindShortestTour[GeoPosition[cities]][[2]];
    GeoListPlot[cities[[tour]], GeoLabels -> True, Joined -> True]] &,
   AllowedCloudExtraParameters -> All], "ShortestTourFunction",
 Permissions -> "Public"]

This is an APIFunction that takes a single parameter, "Location", which must be a "Country":


Notice how the Excel formula creates an image. This is specialized functionality built for CloudConnector that allows you to make changes to spreadsheet values to trigger updates to this image. With this short amount of code, you can connect your spreadsheets to the full computational power of the Wolfram Language.

Wolfram CloudConnector for Excel creates a user-focused, feature-filled link from Excel to the Wolfram Cloud, while cutting developer time for more advanced computation. CloudConnector is a free plugin that runs on Excel for Windows. It does not require any additional Wolfram technology to be installed—just an appropriate Wolfram Cloud Account to create APIs. CloudConnector for Excel is available now for use in both the Wolfram Cloud and Wolfram Enterprise Private Cloud.

Leave a Comment


Kala Vance

This is amazing!

Posted by Kala Vance    November 5, 2019 at 10:22 am
David Reiss

Although you refer to “escaped quotes”, I do not see an escape sequence in the example within the Excel input — rather I see two quote characters in sequence. Is Excel not displaying the \ character? If so then perhaps that is on Excel to fix, but it is quite confusing to the user.

Posted by David Reiss    November 5, 2019 at 10:25 am
    Anthony Zupnik

    Hi David, In Excel the easiest way to put a double quote into a string is by adding 2 double quotes sequentially. There are other ways to do this but its even more confusing. Anthony

    Posted by Anthony Zupnik    November 5, 2019 at 6:44 pm
    Gerli Jõgeva

    Using double quotes is indeed how you escape quotes in Excel (not using a backslash)

    Posted by Gerli Jõgeva    November 6, 2019 at 5:13 am
    Edwin Steiner

    I think the doubling of the quotes counts here as the escaping mechanism.
    “Escaping” does not necessarily refer to a backslash sequence. It has the more general meaning of making a character “escape” from the way it would normally be treated in a certain context. Prepending backslash and doubling are two frequently used mechanisms for implementing this general idea.

    Posted by Edwin Steiner    November 6, 2019 at 6:43 am

thank you for this …

Posted by DAN ELLWEIN    November 7, 2019 at 11:00 am

Leave a comment