Use the setFormula method in the Worksheet class for specifying the formula. Returning the value of the formula property provides a string containing the written expression of the formula, for example, SUM(A1:B1).
In code the setting of a formula would look something like this in JavaScript (for illustration purposes only):
sheet.getCell(2, 0).formula = "SUM(A1:A10)"
and if added in the cell by the end user:
=SUM(A1:A10)
In this documentation, where examples are shown, the formula appears as:
SUM(A1:A10)
or
SUM(3,4,5) gives the result 12
to express that the result of the formula would display the value of 12 in the cell.