I don’t officially support formulas (yet). But it is something I have ideas for. Not sure if free or pro yet to be honest. We’ll see. ??
But I have a sneaky hook build in (ssshhtt). It’s called: gfexcel_renderer_cell_properties
.
But I just realized I have not implemented this properly. So to work with it you need to edit line 314 in AbstractPhpExcelRenderer.php
to say:
gf_do_action(
['gfexcel_renderer_cell_properties'],
$cell,
$value
);
So the hook needs to be wrapped in an array.
It has 2 params, so you have to add it with 10, 2
on the add_filter to use both. You can directly “speak” to the cell in from phpspreadsheet
(the underlying library).
I’m not sure if this will work but you can have a try (using add_action
because the hook is also a do_action
):
add_action('gfexcel_renderer_cell_properties', static function(\PhpOffice\PhpSpreadsheet\Cell\Cell $cell, $value) {
if ((string) $value === 'Your formula goes here exactly') {
$cell->setDataType(\PhpOffice\PhpSpreadsheet\Cell\DataType::TYPE_FORMULA);
}
}, 10, 2);
But this is highly experimental, and I cannot give you any guarantees this will work how you want. (I’ll fix the hook in the next release).
-
This reply was modified 4 years, 2 months ago by Doeke Norg. Reason: line position
-
This reply was modified 4 years, 2 months ago by Doeke Norg.