Bug 154576 - Recalculate changes percent format of average formula
Summary: Recalculate changes percent format of average formula
Status: NEW
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: BASIC (show other bugs)
Version:
(earliest affected)
unspecified
Hardware: All All
: medium normal
Assignee: Not Assigned
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2023-04-03 00:11 UTC by NOYB
Modified: 2023-04-03 11:32 UTC (History)
1 user (show)

See Also:
Crash report or crash signature:


Attachments
Calc Spreadsheet with macro demonstrating bug (10.68 KB, application/octet-stream)
2023-04-03 00:16 UTC, NOYB
Details

Note You need to log in before you can comment on or make changes to this bug.
Description NOYB 2023-04-03 00:11:42 UTC
Description:
Cells with an average formula and formatted as #,##0.000%;[RED]-#,##0.000% are in some cases changed to 0.00% format (11) upon calculation.

Steps to Reproduce:
1. Manually format A1:B2 as -12.950%; #,##0.000%;[RED]-#,##0.000%
2. Run the included macro (Sub Main)


Actual Results:
B1 is formatted as -12.95%; Format Code: 0.00% (11)

Expected Results:
B1 format should remain unchanged as -12.950%; Format Code: #,##0.000%;[RED]-#,##0.000%


Reproducible: Always


User Profile Reset: No

Additional Info:
Sub Main
  Dim nformat As Long
  With ThisComponent.Sheets(0)
    nformat=.getCellRangeByName("B1").NumberFormat
    ThisComponent.EnableAutomaticCalculation(False)
    
    .getCellRangeByName("A:B").ClearContents(1023)   ' all formats are removed!

    .getCellRangeByName("B1").setFormula("=AVERAGE(A1:A2)")
    .getCellRangeByName("A1").setValue(0.50)
    .getCellRangeByName("A2").setValue(0.6667)

    .getCellRangeByName("A1:B2").NumberFormat=nformat    ' restore formats A1:B2 

    MsgBox "Format before calculation:" & .getCellRangeByName("B1").NumberFormat
    ThisComponent.EnableAutomaticCalculation(True)
    MsgBox "Format after calculation:" & .getCellRangeByName("B1").NumberFormat
  End With
End Sub


Version: 7.5.2.2 (X86_64) / LibreOffice Community
Build ID: 53bb9681a964705cf672590721dbc85eb4d0c3a2
CPU threads: 8; OS: Windows 10.0 Build 22621; UI render: Skia/Raster; VCL: win
Locale: en-US (en_US); UI: en-US
Calc: threaded
Comment 1 NOYB 2023-04-03 00:16:30 UTC
Created attachment 186423 [details]
Calc Spreadsheet with macro demonstrating bug