RRI formula not working in macro

This macro results in cell C5 “=rri(1,$A$1,$A$5)”.
However, #NAME? is displayed rather than the value.

Editing the cell, replacing any formula character with itself, converts the formula name to uppercase and displays the value.

The “AVERAGE” formula works fine. Why doesn’t the “RRI” formula work as expected?

Example spreadsheet with macro attached.
Macro RRI Formula.ods (11.6 KB)

Sub Main
ThisComponent.Sheets.getByName(“Sheet1”).getCellRangeByName(“C5”).setFormula("=RRI(1;$A$1;$A$5)")
ThisComponent.Sheets.getByName(“Sheet1”).getCellRangeByName(“A6”).setFormula("=AVERAGE($A$1:$A$5)")
End Sub

Version: 25.8.4.2 (X86_64)
Build ID: 290daaa01b999472f0c7a3890eb6a550fd74c6df
CPU threads: 8; OS: Windows 11 X86_64 (build 26200); UI render: Skia/Raster; VCL: win
Locale: en-US (en_US); UI: en-US
Calc: threaded

Why don’t you debug?
Enter the correct formula manually.
Then call print oCell.getFormula()

… why stop there → Development/How to debug - The Document Foundation Wiki :expressionless:

looks like a gory legacy trick as explained by @erack :
https://cgit.freedesktop.org/libreoffice/core/commit/formula?h=cp-22.05.5-1&id=8f9cb3dddd2f

ODFF: write RRI as RRI, not ZGZ

ODF OpenFormula defines the function RRI, the legacy OOo XML format stored that as ZGZ but that was not changed for the ODFF implementation. Correctly read/write RRI now but still accept ZGZ to be able to load existing documents.