https://bugs.documentfoundation.org/show_bug.cgi?id=131564

--- Comment #4 from Andreas Heinisch <andreas.heini...@yahoo.de> ---
There exists a workaround, if you set the locale. However, it is still an
inconvenience.

Function cellRange_SetNumberFormat( strSourceRange As String, strNumberFormat
As String ) As Long
REM Sets the Number Format of the specified CellRange to <strNumberFormat>.
REM <strNumberFormat> : The desired Number Format specification string (e.g.
"0.00").
REM NB. The given Format will be added to the NumberFormats, if it doesn't
exist already.
    Dim aLocale As New com.sun.star.lang.Locale
    Dim oNumberFormats As Object    : oNumberFormats =
ThisComponent.getNumberFormats()
    Dim oSheet As Object    : oSheet =
ThisComponent.CurrentController.ActiveSheet
    Dim oRange As Object    : oRange = oSheet.getCellRangebyName(
strSourceRange )
    Dim lFormatKey  As Long : lFormatKey = oNumberFormats.queryKey(
strNumberFormat, aLocale, FALSE )
    If lFormatKey = -1 Then   lFormatKey = oNumberFormats.addNew(
strNumberFormat, aLocale )
    oRange.NumberFormat = lFormatKey
    cellRange_SetNumberFormat = lFormatKey
End Function

Sub Main
    cellRange_SetNumberFormat("B1:B2", "0.0%")
End Sub

-- 
You are receiving this mail because:
You are the assignee for the bug.
_______________________________________________
Libreoffice-bugs mailing list
Libreoffice-bugs@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-bugs

Reply via email to