Set default percent format in Calc

Hi,

Whenever I create a new Calc sheet and apply the Percent format, the number is 10000,00%

What I actually need is 100%, so each time I have to manually change the formatting:

Can I change the default format permanently?

What did you enter into the cell? what was calculated for it?

You can define and apply a cell style with percent format string “0%” (no decimals).
You can not change the fact that 100=10000%.

There are two issues anyway:

  1. You cant change the default percent format for automatic application.
  2. If a cell is already formatted as a percentage, an input number like “55” is interpreted as “55%”. That’s illogical, but people seem to like it this way.
1 Like

What did you enter into the cell? what was calculated for it?

Here are my steps:

  1. Open LibreOffice Calc
  2. Type 100% in any cell
  3. Press Enter

The result is displayed as 100,00%, but I want it to show simply 100%.

If a cell is already formatted as a percentage, an input number like “55” is interpreted as “55%”.

Are you sure? Look at this steps:

  1. Open LibreOffice Calc
  2. Select some cells
  3. Press Ctrl+Shift+5 to format as percentage
  4. Type there 100%

The result is still displayed as 100,00%, but I want it to show simply 100%.

So every time I have to use the Ctrl+1 shortcut and change the percent format (as shown in the previous screenshot).

Yes, but I didn’ word it precisely enough.
My point was the automatic division by 100: You enter “55” without a %-sign, but the cell will show 55% which has the “unformatted” value of 0.55 . I didn’t want to claim that the decimals will be suppressed - except if the predefined percentage format was defined to do it otherwise.

This will be asl long as the number format of the cell is “0.00%”. This is the unchangeable default also if the mentioned shortcut is used.

In cases I know number-format defaults (decimal separator, dates …) are defined by the used locale. Ther is no locale I know of which uses “0%” for so-called percentages.
It may be possible do create a locale with that unusual default, but I neither knoe if nor how.

Simply don’t expect any cell to set a non-default percentage format, but define a cell style and assign it to cells where actually percentages will be used. This I recommended earlier.

We can use a macro to reassign this keyboard shortcut to format as whole percentages.

  1. Add the following macro to any module in any library from “My Macros.”
  2. Assign this macro to any keyboard shortcut you prefer (you can use Ctrl + Shift + 5)

The macro takes into account the (rare) possibility of having different locales for formatted cells.

Sub SetNumberFormatPercentInt(Optional Byval arg as Object)
  Dim oDoc as Object, oRanges as Object, oRange as Object, oNumberFormats as Object
  Dim nFIndex as Long
  If IsMissing(arg) Then arg = ThisComponent.CurrentSelection
  nFIndex = com.sun.star.i18n.NumberFormatIndex.PERCENT_INT
  If HasUnoInterfaces(arg, "com.sun.star.sheet.XSheetCellRange") Then
    oDoc = arg.Spreadsheet.DrawPage.Forms.Parent   
    With oDoc.NumberFormats
    
      If arg.supportsService("com.sun.star.sheet.CellRange") Then
        arg.NumberFormat = .getFormatIndex(nFIndex, .getByKey(arg.NumberFormat).Locale)
      Else
        For Each oRanges In arg.getUniqueCellFormatRanges()
          oRanges.NumberFormat = .getFormatIndex(nFIndex, .getByKey(oRanges.NumberFormat).Locale)
        Next oRanges  
      End If    
    End With  
  
  ElseIf HasUnoInterfaces(arg, "com.sun.star.sheet.XSheetCellRanges") Then
    For Each oRange In arg
      SetNumberFormatPercentInt oRange
    Next oRange  
  End If
End Sub
1 Like