Every cell has one value, one string and one formula at the same time.
A number format must not change the value or formula. A number format changes the appearance of a value but never the value itself.
All cell values are either text or numbers. Formulas may return error as a third type.
Any booleans, dates, times etc. are formatted numbers. 2018-02-28 and 43159. are formattings of the exact same cell value.
The type of value, the value and the string depend on the cell formula.
The value is the numeric result of the formula. The text is the visual representation of the cell's value according to the formatting. The formula can be seen as the "true content" which determines everything.
A blank cell has a zero value and "" as string and formula.
A cell with formula '1 (leading apostrophe) shows the text "1" and has the value 0. This is what you get from c.setString("1") or c.setFormula("'1")
A cell with formula 1 (no apostrophe) has a value of 1 and the text may be anything dependent of the format. This is what you get from c.setValue(1) or c.setFormula("1").
A cell with formula '=SUM(A1:B4) (leading apostrophe) shows the literal text =SUM(A1:B4) and has the value 0. c.setString("=SUM(A1:B4)") or c.setFormula("'=SUM(A1:B4)")
setValue(num) puts a number into the cell. The cell value is always a double, although you may use integers in your program.
setString(txt) puts a text into the cell. The value is reset to 0.
setFormual(txt) puts anything into the cell. A number ("1"), a text or a calculated expression (starting with "=").
Property FormulaLocal is the localized variant of the formula. It is the string you see in the formula bar.
[UNO, Calc] How to fill spreadsheets cells programmatically