Number format code question

Number format codes as described here:
‘’‘Number Format Codes’’’
aren’t usable as cell.numberformat, are they any use in basic macros or only in the Calc user interface?
Thanks,
Mike

shows the use of NumberFormats.queryKey/NumberFormats.addNew.

Hallo

some_cell.NumberFormat is just a mapping from »some Number Format Code« to an integer.
For Example, the …NumberFormat 49 is mapped to Iso-Date-Format-Code yyyy-mm-dd ( at least actually with my Locale-Setting. AFAIK there is no warranty for the very same mapping at any time and Locale-Setting?! )

in Basic you may use the runtime-function format( any_number, "<your_format_code>" )

Thanks for the info fellas.
From what I gathered you can’t use Number Format Code as cell.numberFormat but can use thenm to find a numeric format number or get a formatted string which Format() returns if I understand correctly.
Be Well,
Mike

For format index 49 it exactly is, but that is not ISO date YYYY-MM-DD but the Text @ format instead, see also LibreOffice: com::sun::star::i18n::NumberFormatIndex Constant Group Reference. The defined ISO date YYYY-MM-DD code for each and all locales is assigned format index 33, see LibreOffice: com::sun::star::i18n::NumberFormatIndex Constant Group Reference. The UNO API defines the index values as named numeric constants, 33 would also be DATE_DIN_YYYYMMDD, I’d guess you somehow could use them also in BASIC(?). Some additional information about semantics is in the comments of https://opengrok.libreoffice.org/xref/core/i18npool/source/localedata/data/locale.dtd?r=f3811e06b27afcbac7f63c2d184db4b1f8b01a1f#227 ff. for locale data implementers.

1 Like