[Solved] thousands separator

Creating a macro - Writing a Script - Using the API (OpenOffice Basic, Python, BeanShell, JavaScript)
Post Reply
kaggb
Posts: 7
Joined: Tue Jan 27, 2009 9:22 pm

[Solved] thousands separator

Post by kaggb »

Does anyone know how for a particular cell in a spread sheet you can determine what the thousands separator is.
    Last edited by kaggb on Sat Feb 07, 2009 7:36 pm, edited 1 time in total.
    OOo 2.3.X on MS Windows Vista
    User avatar
    Villeroy
    Volunteer
    Posts: 31279
    Joined: Mon Oct 08, 2007 1:35 am
    Location: Germany

    Re: thousands separator

    Post by Villeroy »

    With the kind help of the MRI tool http://extensions.services.openoffice.org/project/MRI

    Code: Select all

    Sub Main
    globalscope.basiclibraries.loadlibrary("Calc")
    c = getActiveCell(thiscomponent.getcurrentcontroller())
    nf = c.NumberFormat
    oNF = thisComponent.NumberFormats.getByKey(nf)
    ' mymri oNF
    oLoc = oNF.Locale
    i18n = createUnoService("com.sun.star.i18n.LocaleData")
    ' oInfo = i18n.getLanguageCountryInfo(oLoc)
    ' mymri oInfo
    oItem = i18n.getLocaleItem(oLoc)
    mymri oItem
    End Sub
    
    Helper in lib Standard:

    Code: Select all

    Sub myMRI(obj)
    	GlobalScope.BasicLibraries.loadlibrary("MRILib")
    	MRILib.Module1.MRi obj
    End Sub
    
    Helper in lib "Calc":

    Code: Select all

    '-------usefull helper-function, returning focussed cell 
    'by UROS > http://www.oooforum.org/forum/viewtopic.phtml?t=19348
    REM 2006-08-09: fixed error when row > 8191
    '		 ;sh;							;lSheet +3
    '100/60/0;1;tw:309;2/2/0/0/0/0/2/0/0/0/0;253/8191/0/0/0/0/2/246/0/0/8158;0/0/0/0/0/0/2/0/0/0/0
    '100/60/0;1;tw:309;2/2/0/0/0/0/2/0/0/0/0;253+8192+0+0+0+0+2+246+0+0+8158;0/0/0/0/0/0/2/0/0/0/0
    Function getActiveCell(oView)
    Dim as1(), lSheet&,lCol&,lRow$, sDum as String,bErr as Boolean
    	as1()  = Split(oView.ViewData, ";")
    	lSheet = CLng(as1(1))
    	sDum = as1(lSheet +3)
    	as1() = Split(sDum, "/")
    	on error goto errSlash
    		lCol = CLng(as1(0))
    		lRow = CLng(as1(1))
    	on error goto 0
    	getActiveCell = oView.Model.getSheets.getByIndex(lSheet).getcellByPosition(lCol,lRow)
    exit Function
    errSlash:
    	if NOT(bErr) then
    		bErr = True
    		as1() = Split(sDum, "+")
    		resume
    	endif
    End Function
    
    The com.sun.star.i18n.LocaleDataItem of a German active cell yields:
    MRI Tool wrote: (Name) (Value Type) (Value) (AccessMode)
    LongDateDayOfWeekSeparator string , [ReadWrite]
    LongDateDaySeparator string . [ReadWrite]
    LongDateMonthSeparator string [ReadWrite]
    LongDateYearSeparator string [ReadWrite]
    dateSeparator string . [ReadWrite]
    decimalSeparator string , [ReadWrite]
    doubleQuotationEnd string “ [ReadWrite]
    doubleQuotationStart string „ [ReadWrite]
    listSeparator string ; [ReadWrite]
    measurementSystem string metric [ReadWrite]
    quotationEnd string ‘ [ReadWrite]
    quotationStart string ‚ [ReadWrite]
    thousandSeparator string . [ReadWrite]
    time100SecSeparator string , [ReadWrite]
    timeAM string vorm. [ReadWrite]
    timePM string nachm. [ReadWrite]
    timeSeparator string : [ReadWrite]
    unoID string "" [ReadWrite]
    Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
    Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
    Post Reply