UPDATE 2022-12-01
This question is now obsolete. Smartsheet API now supports the requested feature. The accepted answer contains more details on the update.
CONTEXT
A developer wishes to populate an existing smartsheet worksheet using the smartsheet API. The data to populate consists of both data and formulas.
However, according to the API documentation (http://www.smartsheet.com/developers/api-documentation) formulas cannot be added using the API.
Cells containing formulas, links to other cells, system values, or Gantt values cannot be inserted or updated through the API.
PROBLEM
Testing verifies this. Attempting to add a simple formula using the smartsheet API causes the formula to be transformed to opaque text. Inspection reveals that the formula is modified with the single quote character, which renders it as opaque text instead of a formula.
QUESTION
Is there any way (other than through manual entry) to force smartsheet to re-evaluate the opaque text inserted, so as to transform the opaque text back into a formula?
If it is not possible (other than through manual entry) is it possible to copy an existing sheet that has formulas in place, and then populate the non-formula data into the sheet, all using the smartsheet API?
GOAL
The basic goal is to find a way to populate formula data into the smartsheet application without having to require manual entry of the formula data.
Update: Smartsheet does now support adding or updating formulas via the API which can be found in the documentation for adding a row and updating a row.
The main difference is to set the
formula
in the row object instead of setting thevalue
.Original Answer
You are correct, formulas are not currently supported via the API. Although, we do plan to add this functionality in the future.
Currently, if you try to send a formula to the API it will be handled as a string and a single quote will be added to the beginning of the formula. Then the only way to convert the string back to a formula is to manually remove the single quote when inside the Smartsheet UI.
Available Option
Your suggestion to use a template will definitely work if you will always be using the same formulas. The process will look like the following:
I have added two examples below one using curl and the other using our Java SDK.
Curl Example
Create a new sheet from the Template. Make sure to replace
YOUR_TOKEN
andYOUR_TEMPLATE_OR_SHEET_ID
in the below command.Then take the sheet id from the response and issue a command to get the row id's.
Last, grab the row id and column id from the response and issue a command to update the appropriate cells. I'm updating two cells with the values 1 and 2 with the below command.
SDK Example
This example requires installing our Java SDK. There is also a C# SDK that works in a very similar fashion.