I'm not sure if this is possible. I have tons of spreadsheet, and the formulas need to be updated. How do I copy a formula from one cell or a group of cells to another? I've used gspread
and it seems it can only do values. I need python to basically paste formulas on hundreds of sheets for me, without me opening each individually and copy and pasting the formulas.
Does anybody have a generic solution for copying and pasting formulas? This is pretty important, you would think someone can do it.
Update 19 July 2018:
Here's how you do it:
(this works since gspread 3.0.0 which uses Sheets API v4.)
Original answer below:
To access a formula value, you need to use the
input_value
attribute of a cell object.Here's an example. (I'm skipping the initialization step. Let's assume you've already opened a spreadsheet and
wks
is referring to you worksheet object.)For a group of cells, you'd want to use a
wks.range()
method to get cell objects. Then you can get formula values viainput_value
as in the code above. See the example on the GitHub.