Is there support, or do others know of another python library that supports something similar to the functionality in Excel that allows for Copy and Paste (Values & Formatting)?
I have been using the WorksheetCopy class, and in the _copy_cells helper function it copies the value and data_type. I see the value comes as a formula if the cell value is a formula and was wondering if there is functionality for getting the computed value of the formula from the cell, not the formula itself.
On 2 Sep 2024, at 21:02, Luke Van Namen wrote:
I have been using the WorksheetCopy class, and in the _copy_cells helper
function it copies the value and data_type. I see the value comes as a
formula if the cell value is a formula and was wondering if there is
functionality for getting the computed value of the formula from the cell,
not the formula itself.
The way to do this is to use two different copies of the workbook with different values for data_only and usually at least one is in read-only mode. This is by design so that there is no ambiguity as to what the value of a cell is and, also, that the cached value potentially becomes invalid as soon as you edit a workbook. In general, however, I suspect it's best to keep the values and pass the workbook to something like OpenOffice in headless mode or xlwings to recalculate the formulae if you want the results.
Charlie
--
Charlie Clark
Managing Director
Clark Consulting & Research
German Office
Sengelsweg 34
Düsseldorf
D- 40489
Tel: +49-203-3925-0390
Mobile: +49-178-782-6226