Trailing zeros in spreadsheet cells

I am using Applescript to extract data from a Numbers spreadsheet to print via a Pages template, the problem is with cells in curreny format are dropping the last decimal zero, i.e. if the cell contains 25.11 it displays as 25.11 but 25.10 displays as 25.1, also 25.00 displays as 25.0 Is there a way to correct this.

There's not really anything to 'correct'. Chances are you're asking Numbers for the 'value' of the cell. The cell's value IS 25.1 (or whatever).
How that number is displayed is independent of its value. You'll note that the returned value doesn't include currency symbols, etc... that's all part of the display format and not its value.
The same thing would happen if you had more than 2 decimal places - 8.2574839 would display as 8.26, but its value remains the full number.
Unfortunately there's no easy way to get the displayed value of a cell via AppleScript.
You're left with manually rounding your values and coercing them to strings with padded 0s:
Fortunately, that's not hard to do:
set theVal to 25.1 --> This is the value extracted from your spreadsheet
set theValString to formatTheNumber(theVal)
on formatTheNumber(v)
          set r to (round (v * 100)) as text -- round off the number
          set theRoundedValString to (text 1 through -3 of r & "." & text -2 through -1 of r) as text -- format it
          return theRoundedValString
end formatTheNumber

Similar Messages

  • Export to excel truncates trailing zeros

    When we try to export to excel trailing zeros are truncated like this:
    In report on BIEE dashboar:
    Product----Amount
    Product A 327,876
    Product B 4,000
    Product C 1,278
    In the exported excel spreadsheet:
    Product A 327,876
    Product B 4
    Product C 1,278
    Any ideas for a solution?

    well it is because excel thinks the the comma is a decimal seperator in stead of a thousands seperator.
    So check your operating system properties and your excel properties.

  • Trailing Zeroes in Table

    Why does Pages REMOVE trailing zeroes in a table? I type 467.6750 and tab to the next cell, and Pages DELETES that ending zero.
    Where can I change that?
    Many thanks.

    clint,
    My guess is that Pages "corrects" the trailing zero because it deems it unnecessary. You can fix it by selecting your table, then clicking on the Table inspector > Format > Cell Format > Text. Assuming you're not using your table to create formulas, treating the numbers as text shouldn't be a problem.
    -Dennis

  • Using excel vi's loses trailing zeroes

    I've been given to write a program that saves columns of numbers to a txt
    file that is in the format of spreadsheet. All the numbers in this file are
    3 places format even if there are trailing zeroes. I am using the excel
    vi's that I downloaded from NI. When I save the file all the numbers lose
    their trailing zeroes. So when the user opens the file using notepad the
    columns tend to not line up anymore. I can format the numbers I am writing
    into strings, but still all the rest of the spreadsheet loses its trailing
    zeroes. I wrote a quick fix that reads all 32 columns and reformats them as
    strings with 3 places, but that is kind of a kludge. Is there a better way?

    "Greg McKaskle" wrote in message
    news:[email protected]..
    > > I've been given to write a program that saves columns of numbers to a
    txt
    > > file that is in the format of spreadsheet. All the numbers in this file
    are
    > > 3 places format even if there are trailing zeroes. I am using the excel
    > > vi's that I downloaded from NI. When I save the file all the numbers
    lose
    > > their trailing zeroes. So when the user opens the file using notepad
    the
    > > columns tend to not line up anymore. I can format the numbers I am
    writing
    > > into strings, but still all the rest of the spreadsheet loses its
    trailing
    > > zeroes. I wrote a quick fix that reads all 32 columns and reformats
    them as
    > > strings with 3 places, but that is
    kind of a kludge. Is there a better
    way?
    >
    > I'm not positive that I understand what is going on, but if you have
    access
    > to the diagrams, you should look for where the numbers are formatted. To
    > format a number as a string and pad with zeroes, you can change the format
    > to %0f, or %08.3f for eight chars with three decimal chars and filled with
    > zeroes.
    In excel ObjectRepository.vi (from excel get data to modify.vi from excel
    save.vi) the diagram can't be viewed without a password. I think that is
    where the data is prepared for saving. I never even knew diagrams could be
    protected like that.

  • How to delete trailing zeros from a quantity field to display in ALV?

    Hi there,
    i am retrieving the field LGMNG from LIPS table, which is of type QUAN(13). All LGMNG values there are stored as
    1,000
    20,000
    50,000 etc.
    But i want my values to be displayed as
    1
    20
    50 etc.
    i have tried the " shift v_variable right deleting trailing '0'" but it does not work.
    also, if the value of LIPS_LGMNG =  0,000, i need those columns in ALV empty(that is no zeros or comma displayed)
    can anyone please help?
    Thanks a lot,
    Mee

    hi,
    use this it will solve your problem, just write down this on your Fieldcatalog.
       WA_FIELDCATALOG-FIELDNAME = 'VALUE7'.
       WA_FIELDCATALOG-SELTEXT_L = 'Contribution EE(due)'.
      WA_FIELDCATALOG-DATATYPE = 'INT2'.           " it will remove trailing zero
      WA_FIELDCATALOG-DECIMALS_OUT = 0.
       APPEND WA_FIELDCATALOG TO IT_FIELDCATALOG.
       CLEAR WA_FIELDCATALOG.

  • I want to remove Trailing zeros from a charecter value

    Hello ,
              i want to remove trailing zeros for a prticular value.Following is my code :
    DATA: V_FLOAT TYPE F VALUE '4.8240000000000000E+03',
               V_CHAR(25) ,
               P10_4(10) TYPE P DECIMALS 4.
    CALL FUNCTION 'CEVA_CONVERT_FLOAT_TO_CHAR'
    EXPORTING
    FLOAT_IMP = V_FLOAT
    FORMAT_IMP = P10_4
    ROUND_IMP = ' '
    IMPORTING
    CHAR_EXP = V_CHAR.
    SHIFT V_CHAR RIGHT DELETING TRAILING '0'.
    WRITE : V_CHAR ."NO-ZERO.
    <u><b>Output:</b></u>
    if we pass the value '1.3000000000000000E+01' it should be 13.0
    ex2: '1.3400000000000000E+01' it should be 13.4
    ex3:'4.8240000000000000E+03' it should be 4824
    is there any way to get the solution without functional module. If so Please tell me with code.

    hi
    u can do it in number of ways.
    Use TCODE SU3
    Select default tab and select radio button 123467.89 in decimal notation and save it.
    or u can try :
    if you want to do this through ABAP program.
    1. to delete trailing spaces.
    SHIFT <V_VARIABLE> RIGHT DELETING TRAILING '0'.
    to delete leading zeroes,
    SHIFT <VARIABLE_NAME> LEFT DELETING LEADING '0'.
    only for one abap program, u can use set country command
    for all programs :
    sap menu>system->go to user profil->own data>default --> and choose ur format.
    hope this helps u.
    Regards,
    Prasanth
    Reward all hepful replies

  • How do I get a 0 to display when a count = 0 (zero)? (The cell is blank)...

    (Running Business Objects Release 2 (Web-I), No other reporting modules)
    How do I get a 0 to display when a count = 0 (zero)? (The cell is blank)...
    In my reports, I count the number of tests of one of our products and another count on the number of failures.  I then use a simple formula to give me the defect rate percentage (DR%)
    The universe objects used in the calculation are:
    Assembly Number (dimension)
    Human Sn (dimension)
    Test Code Description (dimension)
    I created a variable (called [Count Assys]) that counts the number of Assemblies Tested:
    Formula: =Count([Assembly Number];All)
    Another variable (called [Failed Count]) counts the number of failed tests:
    Formula: =Count([Test Code Description];All) Where ([Test Code Description] <> "FUNCTIONAL TESTS PASSED")
    NOTE: There is a "not equal to sign" between [Test Code Description] and "FUNCTIONAL..." above, but the forum is blanking it when I preview the message.  Not a big deal, but it may be important for someone looking to help...
    I then have a third variable called [DR%] that divides [Failed Count] into the number of [Count Assys], which yields a number formatted as a percentage.
    Formula: =[Failed Count]/[Count Assys]
    The above works great! 
    The problem is: when I have a zero defect count (everything passes), the cell is blank, so the percentage variable remains blank.  I want a zero (0) to appear if nothing failed so the percentage appears as 0%
    I've searched this forum completely and have tried several Properties changes and different variable strings (like =If([Failed Count]<1,0) and the cell stays blank and cannot come up with an answer.
    This one seems simple to me, but everything I've tried has yielded zero <smile> results.
    Thanks,
    Charles
    Edited by: Charles Norman on Dec 9, 2008 12:44 PM
    Edited by: Charles Norman on Dec 9, 2008 12:47 PM

    Hi Charles,
    Use [Dr%] Variable formula as =if(IsNull([Dr%]);0;[DR%])
    Here IsNull returns the Boolean value of variable [Dr%] if its true then inserts 0 else the percentage values of failed tests based on the  total number of assembly tests performed.
    I Hope this is what you want to achieve....
    Thanks....
    Pratik

  • How can i retain the trailing zeroes after decimal

    how can i retain the trailling zeros after decimal?
    values are showing in table like( 4.50,5.00) but i am trying to do some processing with these values then ithe zeroes are truncated like (4.5,5),
    how can i get values with zeroes

    If the values in the table have trailing zeroes, it's a character type column.
    Once you perform operations on them, they're implicitely converted to the number type, hence "losing" trailing zeroes.
    To get the trailing zeroes back, you have to convert them back to character data:
    TO_CHAR(1.5*3, '90d99')Have fun,
    K.

  • Remove trailing zeroes in quantity field.

    Hi all,
    I am having quantity field in ALV grid display : VBAP-KWMENG. Iam getting quantity value as 1,000.My requirement is to get quantity value as 1.(without ',' and zeroes).
    Suggest me a suitable solution.
    Thanks all.

    Other way is check for the below code ..
    DATA:
      lv_decimal TYPE f DECIMALS 3,
      lv_string  TYPE string.
    lv_decimal = '22.010'.
    WRITE lv_decimal TO lv_string.
    SHIFT lv_string RIGHT DELETING TRAILING '0'.
    * also delete trailing '.', if possible
    SHIFT lv_string RIGHT DELETING TRAILING'.'.
    CONDENSE lv_string NO-GAPS.
    * now no trailing zeros are in the decimal stored in LV_STRING

  • How to get PL/SQL output in Excelsheet & preserve trailing zero for VARCHAR

    Hi All,
    I am trying to get the PL/SQL procedure out put to Excel sheet, I have wrote below code and it worked fine.
    CREATE OR REPLACE PROCEDURE plsql_to_excel_demo IS
    CURSOR cur_stock_details
    IS
    SELECT *
    FROM stocks;
    outfile UTL_FILE.file_type;
    l_chr_string VARCHAR2(100);
    l_chr_col_header VARCHAR2(100);
    l_chr_file VARCHAR2(100);
    l_chr_date VARCHAR2(20);
    BEGIN
    SELECT TO_CHAR(sysdate,'DD_MON_YYYY')
    INTO l_chr_date
    FROM dual;
    l_chr_col_header :='SYMBOL'||CHR(9)||'COMPANY'||CHR(9)||'CURRENT_PRICE'||CHR(9)||'TRADE_DATE'||CHR(9)||'NUMBER_TRADED_TODAY'
    ||CHR(9)||'TODAYS_HIGH'||CHR(9)||'TODAYS_LOW';
    l_chr_file := 'STOCK_REPORTS_'||l_chr_date||'.xls';
    outfile := UTL_FILE.FOPEN ('/u01/app/UTL/out',l_chr_file, 'W');
    UTL_FILE.PUT_LINE(outfile,l_chr_col_header);
    FOR rec_stock_details IN cur_stock_details LOOP
    /*l_chr_string := rec_stock_details.symbol||CHR(9)||''''||rec_stock_details.company||''''||CHR(9)
    ||rec_stock_details.current_price||CHR(9)||
    TO_CHAR(rec_stock_details.trade_date,'DD/MM/YYYY')||CHR(9)||rec_stock_details.number_traded_today||CHR(9)||
    rec_stock_details.todays_high||CHR(9)||rec_stock_details.todays_low;
    l_chr_string := rec_stock_details.symbol||CHR(9)||rec_stock_details.company||CHR(9)||rec_stock_details.current_price||CHR(9)||
    TO_CHAR(rec_stock_details.trade_date,'DD/MM/YYYY')||CHR(9)||rec_stock_details.number_traded_today||CHR(9)||
    rec_stock_details.todays_high||CHR(9)||rec_stock_details.todays_low;
    UTL_FILE.PUT_LINE(outfile,l_chr_string);
    END LOOP;
    UTL_FILE.FCLOSE (outfile);
    EXCEPTION
    WHEN OTHERS THEN
    dbms_output.put_line ('Error in main '||SQLERRM);
    END plsql_to_excel_demo;
    I am facing the issue when I have VARCHAR2 column say Company in stocks table with value as 0000234. When I get the data Excel
    sheet I can only see 234
    for company name. I want to preserve the trailing zeros while getting the output in Excel sheet.
    I have tried with adding single quote (') please see the commented part in the above code, but it will give me output in company
    column in excel '0000234' which i don't want.
    Is there any way I can make this work and only get 0000234 as company name in Excel.
    Thanks for reading the post..
    regards,
    Shyam.
    Edited by: Suryawanshi on Mar 22, 2010 5:40 PM

    Yes, that should be a client (excel, or open office in my case) issue.
    I stole some code from http://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION_ID:95212348059 to test this out.
    Adding a single quote to the beginning of the string worked fine with my version of Open Office, should work for your Excel as well.
    create table varchar2_test(col1 varchar2(10), col2 number(10));
    insert into varchar2_test values ('000189', 10);
    create or replace function  dump_csv( p_query     in varchar2,
                                          p_separator in varchar2 default ',',
                                          p_dir       in varchar2 ,
                                          p_filename  in varchar2 )
    return number
    is
        l_output        utl_file.file_type;
        l_theCursor     integer default dbms_sql.open_cursor;
        l_columnValue   varchar2(2000);
        l_status        integer;
        l_colCnt        number default 0;
        l_separator     varchar2(10) default '';
        l_cnt           number default 0;
    begin
        l_output := utl_file.fopen( p_dir, p_filename, 'w' );
        dbms_sql.parse(  l_theCursor,  p_query, dbms_sql.native );
        for i in 1 .. 255 loop
            begin
                dbms_sql.define_column( l_theCursor, i, l_columnValue, 2000 );
                l_colCnt := i;
            exception
                when others then
                    if ( sqlcode = -1007 ) then exit;
                    else
                        raise;
                    end if;
            end;
        end loop;
        dbms_sql.define_column( l_theCursor, 1, l_columnValue, 2000 );
        l_status := dbms_sql.execute(l_theCursor);
        loop
            exit when ( dbms_sql.fetch_rows(l_theCursor) <= 0 );
            l_separator := '';
            for i in 1 .. l_colCnt loop
                dbms_sql.column_value( l_theCursor, i, l_columnValue );
                utl_file.put( l_output, l_separator || l_columnValue );
                l_separator := p_separator;
            end loop;
            utl_file.new_line( l_output );
            l_cnt := l_cnt+1;
        end loop;
        dbms_sql.close_cursor(l_theCursor);
        utl_file.fclose( l_output );
        return l_cnt;
    end dump_csv;
    variable x number;
    begin
       :x :=    dump_csv
                   p_query     => 'select '''' || col1, col2 from varchar2_test',
                   p_separator => ',',
                   p_dir       => 'TEST_DIR',
                   p_filename  => 'test_output.xls'
    end;
    print :x

  • Answers report-download as Excel loose trailing zeroes

    Hi!
    When I download Answers report to Excle (Word) I loose trailing zeroes.
    1.2500 -> 1.25Trailing zeroes are important and I'd like that format remain as it is in OBI in all downloading types (Excel, Word etc).
    When I export to PDF (run through Oracle BI publisher) trailing zeroes are correct.
    Any help please.
    My config, OBI on Windows 2003 32 bit:
    Product Information
    Oracle Business Intelligence Product Version     10.1.3.4 (Build 080726.1900)
    Physical Presentation Catalog Path     \\?\C:\OracleBIData\web\catalog\teb\root
    Oracle BI Server Data Source     AnalyticsWeb
    Available Paging Memory (MB)     5176
    Available Virtual Address Space (MB)     1833

    Hi,
    here are mine data as requested ...
    The only three formating columns are Cash up KN, Cash up EUR i Cash up EUR/KN.
    Column that has problem has no "mso" like formating at all, only two decimal number format, defined in classic way in OBI.
    Generated Excel file from OBI:http://sites.google.com/site/vadasovi/icon_holders-1/BAZA.xls
    How it is opened in Excel 2003:http://sites.google.com/site/vadasovi/_/rsrc/1318338523563/Home/temp/2007.PNG , look column in red.
    Same file in Excel 2010 (other mashine then 2003:http://sites.google.com/site/vadasovi/_/rsrc/1318338543353/Home/temp/2010.png
    Both client are Win XP SP3 with Croatian locale (same one in detail).
    Rg,
    Damir

  • Add Trailing  zeros to a number or char

    Hi Experts,
               my material number is stored in the form of Character so i want to add a trailing zero to that number
               supposr for example my material number is ccf5a   so i want add zeroes to make it 18  like   cf5a0000000000000 characters
              Please help me on this  hoping for the quick replay.

    Use [CONCATENATE|http://help.sap.com/abapdocu/en/ABAPCONCATENATE.htm] (only once with a constant initialized with 18 zeroes)
    or
    go to [PAD|http://help.sap.com/abapdocu/en/ABAPCOMPUTE_STRING_FORMAT_OPTIONS.htm#!ABAP_ADDITION_3@3@] in [Embedded expressions format_options |http://help.sap.com/abapdocu/en/ABAPCOMPUTE_STRING_FORMAT_OPTIONS.htm] in [String Templates - embedded_expressions|http://help.sap.com/abapdocu/en/ABENSTRING_TEMPLATES_EXPRESSIONS.htm] in [string_exp - String Templates |http://help.sap.com/abapdocu/en/ABENSTRING_TEMPLATES.htm] in [string_exp - String Expressions|http://help.sap.com/abapdocu/en/ABAPCOMPUTE_STRING.htm] in [Expressions and Functions for String Processing |http://help.sap.com/abapdocu/en/ABENSTRING_PROCESSING_EXPR_FUNC.htm]
    Regards,
    Raymon

  • How to delete Trailing zeros in a string array

    I am reading data from RS232 port and storing the values in an array of 16 nos. Then converting the array of numbers into string using 'number to fractional string" function with precession 2  and sending the data string to Table. I am printing this table further for report generation.
    I am unable to remove the trailing zeros as i am defining precession 2 which is not needed for all the numbers in the table.
    Please help me how to remove the trailing zeros after decimal point which is very much necessary for report generation.
    regards
    Prasanna Kumar N M

    Use format into string in a FOR loop with a format specified of %#f. See attached example (LabVIEW 7.0)
    Message Edited by altenbach on 10-14-2006 05:40 AM
    LabVIEW Champion . Do more with less code and in less time .
    Attachments:
    AutoFormat.vi ‏17 KB
    AutoFormat.png ‏3 KB

  • How to delete trailing zeros after decimal ?

    Hi,
    i want to delete trailing zeros after decimal.
    Example:
    if it is 22.000 then output will be 22
    if it is 22.010 then output will be 22.01.
    plz let me know hw to do this ?

    DATA:
      lv_decimal TYPE f DECIMALS 3,
      lv_string  TYPE string.
    lv_decimal = '22.010'.
    WRITE lv_decimal TO lv_string.
    SHIFT lv_string RIGHT DELETING TRAILING '0'.
    CONDENSE lv_string NO-GAPS.
    * now no trailing zeros are in the decimal stored in LV_STRING
    <REMOVED BY MODERATOR>
    Edited by: Alvaro Tejada Galindo on Jan 30, 2008 12:10 PM

  • IHow to force display of trailing zeros for fixed point numbers?

    I have an 8 bit unsigned fixed point number, with 7 integer bits and 1 fractional bit, so the desired delta is 0.5. I want it to always display the fractional bit, even when that bit is 0. In other words, as this number is incremented, I want to see:
    0.0
    0.5
    1.0
    1.5
    etc.
    But instead I'm seeing:
    0
    0.5
    1
    1.5
    etc.
    I set the display format to Floating point, with 1 digit of precision. The "Hide trailing zeros" checkbox is NOT checked. What am I doing wrong?
    I realize I could convert to single precision for display purposes to make this happen, but I'd rather make this work with fixed point.
    Thanks,
    -Ron

    I just rustled up a VI with what I understand your input to be - unsigned 7 bit mantissa and 1 bit exponent input, and have it displaying 2 decimal places.... Is this what you're after or did I miss it?
    - Cheers, Ed
    Attachments:
    zeros.vi ‏7 KB

Maybe you are looking for