[Solved] Is it possible to modify a built-in number format?

Discuss the spreadsheet application
Post Reply
User avatar
ChasVA
Posts: 16
Joined: Tue May 31, 2016 11:14 am

[Solved] Is it possible to modify a built-in number format?

Post by ChasVA »

There are several built-in number formats available as buttons that can be added to the toolbar:

Image

I want to change Number Format: Decimal from:

Image

to:

Image

Is there a way to accomplish this without creating a Style? Creating a Style won't work, as Styles include other settings for all those other tabs—Font, Font Effects, Alignment, Borders, Background, and Cell Protection—that vary for cells where the modified Number Format: Decimal format is desired. I'd also prefer not to use a macro, but fear that is the only solution.

Is there a way to modify the built-in setting, or an option other than creating a Style or a macro?

Thanks!
Last edited by ChasVA on Sat Dec 30, 2017 6:38 am, edited 2 times in total.
Version: OpenOffice 4.1.5
OS: Win 8.1 64-bit

Never try to second-guess the clueless. Malcolm Gordon
User avatar
RusselB
Moderator
Posts: 6646
Joined: Fri Jan 03, 2014 7:31 am
Location: Sarnia, ON

Re: Is it possible to modify a built-in number format?

Post by RusselB »

Well, seeing as how you don't want to create a macro, you're probably not going to like the only other option that I was able to think of.... namely re-coding the part of the Calc application that controls that information.
So, technically, yes there is another option. Imo, it's not a reasonable option considering you don't want to use a macro.
OpenOffice 4.1.7, LibreOffice 7.0.1.2 on Windows 7 Pro, Ultimate & Windows 10 Home (2004)
If you believe your problem has been resolved, please go to your first post in this topic, click the Edit button and add [Solved] to the beginning of the Subject line.
User avatar
Zizi64
Volunteer
Posts: 11359
Joined: Wed May 26, 2010 7:55 am
Location: Budapest, Hungary

Re: Is it possible to modify a built-in number format?

Post by Zizi64 »

Is there a way to accomplish this without creating a Style? Creating a Style won't work, as Styles include other settings for all those other tabs—Font, Font Effects, Alignment, Borders, Background, and Cell Protection—that vary for cells where the modified Number Format:
Decimal format is desired. I'd also prefer not to use a macro, but fear that is the only solution.

Is there a way to modify the built-in setting, or an option other than creating a Style or a macro?
Study and use the Styles. The Styles are MOST VALUABLE features of the AOO and LO.

You can organize the Styles into a hierarhical structure. The Child Styles will inherit the properties from the Parent Style. And then you must modify only the desired property of the Child Style.



And yes, write (or record) a macro is the another possible solution.
But you need study and use the API functions and one of the supported programming languages for writing a macro. A macro can modify all of the properties (manual/direct properties and/or the properties of the applied style) of a selected cell. You can assign your macro to a toolbar entry, but you must choose one of the built-in icons for the toolbar. (Or you can/must draw and embed your own icons for the new functions...)


Using the Styles seems a simplier way for you.
Tibor Kovacs, Hungary; LO7.5.8 /Win7-10 x64Prof.
PortableApps/winPenPack: LO3.3.0-7.6.2;AOO4.1.14
Please, edit the initial post in the topic: add the word [Solved] at the beginning of the subject line - if your problem has been solved.
User avatar
acknak
Moderator
Posts: 22756
Joined: Mon Oct 08, 2007 1:25 am
Location: USA:NJ:E3

Re: Is it possible to modify a built-in number format?

Post by acknak »

ChasVA wrote:... Styles include other settings for all those other tabs ...
Styles may contain partial settings. If you open the "Modify Style" dialog window and look at the "Organizer" tab, it shows a list of all the settings contained in the style. Settings that are not in the style will come from the style shown in the "linked with" field there.

Removing settings from a style can be done using the "Standard" button at the bottom of the dialog.

As to your question, I think others have answered, but as far as I know, the built-in formats are hard-wired. I don't know how (or if) they can be customized, even if you do use a style. The only way I know of to get a custom number format on a toolbar button is to record or write a macro that applies the formatting, either directly or by applying a named style.
AOO4/LO5 • Linux • Fedora 23
User avatar
keme
Volunteer
Posts: 3704
Joined: Wed Nov 28, 2007 10:27 am
Location: Egersund, Norway

Re: Is it possible to modify a built-in number format?

Post by keme »

Closing parenthesis and space are not the same width in every font. To ensure perfect alignment, end the format code for positive numbers with underscore + parenthesis instead of a space, like so:
#,##0.00_);[RED](#,##0.00)

I made a macro to set that format on selected cells. See attached file. That also sets USA locale for the selection (easier for me to do it that way, because my default locale is not US).

Macro recording took a minute. Another minute to add it to the toolbar with a suitable icon. If you need a well behaved macro for different locales (no locale setting from the macro), do it yourself. That also requires testing in all locales, though.
Attachments
decimalformat.ods
(10.94 KiB) Downloaded 86 times
Post Reply