+ Reply to Thread
Results 1 to 6 of 6

excel default negative numbers

  1. #1
    Registered User
    Join Date
    08-14-2006
    Posts
    57

    excel default negative numbers

    I am exporting a table from a website as HTML straight into Excel.
    I have formatted negative numbers with brackets.
    So -1234 becomes (1234).
    Problem is that when the table goes into excel, it changes them back to -1234

    Any ideas on a way round this?

    I can't do anything in the excel file directly as this is supposed to be like a report from the website and each user can then manipulate the files as needed so I have no control over their machines.

  2. #2
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258
    Hello qwertyjjj,

    Excel has default formats and prefixing a minus sign to a negative number is the default. Unfortunately, default formatting is a machine specific issue. I assume these values need to be seen by Excel as numbers, as they are in a report, so this eliminates sending the data to Excel as text only. What program are you using to export this table to Excel with?

    Sincerely,
    Leith Ross

  3. #3
    Registered User
    Join Date
    08-14-2006
    Posts
    57
    Quote Originally Posted by Leith Ross
    Hello qwertyjjj,

    Excel has default formats and prefixing a minus sign to a negative number is the default. Unfortunately, default formatting is a machine specific issue. I assume these values need to be seen by Excel as numbers, as they are in a report, so this eliminates sending the data to Excel as text only. What program are you using to export this table to Excel with?

    Sincerely,
    Leith Ross
    I'm using PHP but basically it's just exporting HTML to Excel.
    The cell is expoted as the text: (12345) and that is the same as -12345
    Except Excel displays it as -12345 instead of (12345)

    Could I display it with an apostrophe in front '(12345)? Problem then is when someone comes to use formulas it won't count the value.

    You say it is machine specific? What is the setting in Excel that makes negative numbers appear as brackets?

    Could I export the cell in HTML as a formula instead, say =format value, etc.?

  4. #4
    Forum Expert mikerickson's Avatar
    Join Date
    03-30-2007
    Location
    Davis CA
    MS-Off Ver
    Excel 2011
    Posts
    6,229
    Format the cells #;(#);0 and the cell will show negative numbers in parenthesis.
    _
    ...How to Cross-post politely...
    ..Wrap code by selecting the code and clicking the # or read this. Thank you.

  5. #5
    Registered User
    Join Date
    08-14-2006
    Posts
    57
    I can't format the cells as that relies on right clicking the cell and selecting the format.
    I need to do this in the HTML so it is printed on screen as I can't modify Excel through PHP code.

    Needs to be something like =VALUE(FORMAT(variable))

  6. #6
    Registered User
    Join Date
    08-14-2006
    Posts
    57
    apparently the css will work in excel:

    mso-number-format:\#\,\#\#0\.000

    but I need to get this format:
    #,##0_);(#,##0);""-""

    how do you escape these i CSS?

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1