TreeGrid v6.0

Int and Float types

TreeGrid documentation index

 

 

 

Int type shows integer number in selected format.

Float type show floating point number in selected format.

The only difference between the types is that the Int type does not accept the decimal separator and exponent characters while editing.

In the input / output XML is the Float type always in English notation with dot as floating point separator.

 

<C> <cell>        string    Type             [“Text”]              Type=”Int” or “Float”                                                                                                    .

To define Int type, set column or cell attribute Type to “Int”, for Float type set Type to “Float”

 

<C> <cell>        bool       CanEmpty          [0]                                                                                                                                new 6.0 .

If the cell number value differ between 0 and “”. Remember the default value is 0.

If set to 0, the empty input value is always converted to 0. So the cell never contains (empty) string value.

It is good to set it to 0 when the numbers are sources for a Formula.

 

<C> <cell>        string    EmptyValue      [“”]                                                                                                                                new 6.0 .

The string displayed when the date value is entered as empty string.

The cell can contain empty value only if CanEmpty is 1.

It is shown only for display, not for edit.

It is not escaped, it can contain HTML code.

 

<C> <cell>        string    Format                                                                                                                                                         chg 7.0 .

Specifies number string format – how the number will be displayed.

This format string uses almost the same formatting as Microsoft .NET System.DateTime.ToString (string format) function.

 

Empty format

If the Format is not set or is empty (default), the default English format is used with a dot as floating point separator.

 

Standard format

Standard format is one letter format. This format loads user format from file Text.xml, tag <Format>, attributes “n..”

             “g”        General                            (ng = "0.######" , ngg = "0.###### E+00"), for numbers under 1e10 uses ng, above uses ngg.

             “f”         Fixed                  (nf = "0.00")

             “c”        Currency            (nc = "$###########0.00")

             “p”        Percent               (np = "0.00%")

             “r”        Rounded            (nr = "0.0000", nrg = "0.0000 E+00"), for numbers under 1e10 uses nr, above uses nrg.

             “e”        Scientific            (ne = "0.000000 E+000")

 

User format

User format can contain any characters but only few have special meaning and the others are written into output without any change.

Since 6.2 version if there no ‘ and ‘ in format string, no number is shown, only the format string.

             0           Place for a digit, displays digit or 0. If there are more digits than count of 0 and # in integer part, all the rest digits are written left to the first 0 or #

             #           Place for a digit, displays digit or nothing if there are no more digits. Has sense only for decimal part or exponent definition.

             8           (new 7.0) Hidden digit, the digit will not be displayed. Digits are always counted from decimal separator position to both sides.

                           It cannot be combined with ‘#’ in the same number part. It can be used only for left and right side of integer part or left side of decimal part.

                                        Example: Val = “123456.789”, Format = “8000” => Result = “456”; Format = “088” => Result = “1234”; Format = “8.80” => Result = “8”

             .            (Dot) Decimal separator. Displays decimal separator defined in file Text.xml, tag <Format>, attribute DecimalSeparator. (dot by default).

Can be only used only once.

             ,            (Comma) This character has two meanings:

                           If this is placed between any digits characters (‘0’ or ‘#’) left to decimal separator,

there will all three digits separated by thousand separator defined in file Text.xml, tag <Format>, attribute GroupSeparator. (comma by default).

Example:  Val = “123456.789”, Format = “,0.00” => Result = “ 123,456.79”

                           If this is placed between last digit and decimal separator (or to the end if decimal separator is not used),

                                        the value will be divided by 1000. There can be more commas to divide more times.

Example:  Val = “123456.789”, Format = “0,,.00” => Result = “0.12”

             %          Place for ‘%’ character (it is defined in file Text.xml, tag <Format>, attribute Percent). If it is present, the number is also multiplied by 100.

                           To place the % character without multiplying by 100, write it with backslash “\%”

             E, e, E-, E+, e-, e+          Result will use exponential notation. To this location is placed ‘E’ or ‘e’ letter followed by digits of exponent.

                           If used exponential notation, the number of digits before decimal separator is given by count of all digit places (‘0’ or ‘#’) before decimal separator.

                           This letter must be followed by number digit places (‘0’ or ‘#’) to specify number of exponent digits.

                           E or e specifies case of E letter, E+ uses sign + for positive exponents, E- and E uses no sign for positive exponents.

Example:  Val = “123456.789”, Format = “000.000 E+00” => Result = “123.456 E+03”

Example:  Val = “-0.0123456789”, Format = “:0.0000(E000)” => Result = “:-1.2346(E-002)”

             ;            (Semicolon) There can be up to three different formats separated by semicolon.

                           The first format is used for positive numbers (and for 0 if the third format missing), second for negative numbers (without minus sign) and third for 0.

                           Remember, from the negative part is read only string before number and after the number, all other (the number format) is used always from positive part

                           So the negative part can be used only to remove, replace or change position of the minus or change CSS attribute like color by the prefix and postfix.

             \            Escape character, the next character is placed to output without any changes. Use to place format characters as 0 # . , E e + - \ ” ’ %

             ‘xxx’ or “xxx”    Characters in quotes or double quotes are placed to output without any changes. Use to place format characters as 0 # . , E e + - \ ” ’ %

 

For example:      Format=’$0.00’ => “$0.10” or “$12.54”

                           Format=’ #.00##;&lt;span style=\'color:red\;\'>#.00##&lt;/span>;nothing’ => negative numbers in red, 0 as nothing

 

If you want add HTML tags before and after value, use rather cell attributes HtmlPrefix and HtmlPostfix instead of Format.

If you really need to place HTML tags into output (for example to use different HTML tags for positive and negative numbers), set <Cfg NoFormatEscape=’1’>. The HTML tags can be set in Format only, not in EditFormat.

 

<C> <cell>        string    EditFormat                                                                                                                                             upd 6.0.

Format string to display the number for editing. It does not affect the input format of the numbers.

 

<C> <cell>        string    ExportFormat                                                                                                                                                   .

A number format to export to Excel. Used only for Export_Type = 0.

It is specific Excel number to export the number in specific format.

If you don’t know the format for the cell, create xls file with one cell, specify its format you want and save it as web page (html file).

Open this htm file and search style property “mso-number-format” and its value set to the ExportFormat.

 

<Cfg>                bool       NoFormatEscape    [1]                                                                                                                    chg 6.0 .

If set to “”, it means 0 for text and 1 for number and date.

If set to 0, the Format is escaped, so the characters & and < are displayed as they are.

If set to 1, you can use HTML tags in columns Format string, in prefix and postfix for text and anywhere for numbers.

 

global func.      string    NumberToString      (Number num, string format)                                                                                     .

Converts number to string according to format string as in function ToString() in C#.NET.

 

global func.      Number              StringToNumber      (string str, string format)                                                                                            .

Converts string to number

 

Localization

 

The default number format and setting are specified in Text.xml, in <Lang><Format /></Lang> tag.

The default settings is for English language, changing the Format tag attributes you can easily localize it to another language.

 

<Format>          string    DecimalSeparator   [.]                                                                                                                                  .

The string displayed as floating point separator.

 

<Format>          char[]    InputDecimalSeparators           [.,]                                                                                         new 6.0 .

The characters permitted to input as decimal separator.

 

<Format>          string    GroupSeparator       [,]                                                                                                                                  .

The string displayed as thousands separator.

 

<Format>          char[]    InputGroupSeparators  []                                                                                                        new 6.0 .

The characters permitted to input as group separator.

Now it should be empty because it is not permitted to input numbers with group separator.

 

<Format>          string    Percent                  [%]                                                                                                                                            .

The string displayed as percentage character.

 

<Format>          string    NaN               [NaN]                                                                                                                                         .

String displayed for incorrect number – Not A Number.