Description: Hi I am using array formulas. For some reason, while using macros or sorting or something else, the array formulas go away and I am left with simple formulas (ie SUM(...) instead of {SUM(...)} I want to write a macro to reset these cells to array formulas, but setformula does not seem to work with an array formula. It sets a string. Thank you for looking Christophe Steps to Reproduce: The data Cells A1 contain 1, A2, 4, B1, 0, B2, 1. Array formula {=SUM((A1:A2)*(B1:B2))} yields 4 while =SUM((A1:A2)*(B1:B2)) yields 0. This is fine The macro instructions oBug.getCellByPosition(2,0).setFormula("=SUM((A1:A2)*(B1:B2))") has a cell type 3 (=FORMULA) Whereas oBug.getCellByPosition(2,0).setFormula("{=SUM((A1:A2)*(B1:B2))}") has a cell type 2 (=STRING) I did not find a way to set the cell type to FORMULA. Actual Results: cell type 2 (=STRING) Expected Results: cell type 3 (=FORMULA) Reproducible: Always User Profile Reset: No Additional Info: I am using the French Libreoffice version.
(In reply to christophe.alviset from comment #0) > I am using array formulas. For some reason, while using macros or sorting or > something else, the array formulas go away and I am left with simple > formulas (ie SUM(...) instead of {SUM(...)} > > I want to write a macro to reset these cells to array formulas, but > setformula does not seem to work with an array formula. It sets a string. Please try with setArrayFormula(), e.g: ThisComponent.getSheets().getByIndex(0).getCellByPosition(0,2).setArrayFormula("=SUM((A1:A2)*(B1:B2))")
Thanks a lot