Export to Excel - Negative value in Parenthesis

Sbhat
Member Posts: 301
I have a report that exports to excel. On the report i have a variable called 'NetLoss' which is of type Decimal and when there is a negative value then i want to show the value in parenthesis in Excel. For example NetLoss := -5000, i want to show it in excel as (5000) without the negative sign. No matter what i do when it goes to excel it just shows it as -5000, i tried '('+format(Netloss)+'), also i tried DELCHR function to remove the negative sign and no luck and then in MakeDataexcelbody i have
Addcolumn(Netloss,' ',true,true,false).
Does anyone know what can be done to make it work such that it shows (5000).
S.
Addcolumn(Netloss,' ',true,true,false).
Does anyone know what can be done to make it work such that it shows (5000).
S.
0
Comments
-
format(-Netloss)
orformat(ABS(Netloss))
The first one: all values change the sign (vice versa)
The second one: always positive.
Decide yourself.0 -
Excel treats a column with () as a negative number so copy/paste this code:
TxtValue := '( ' + FORMAT(ABS(<NegativeDecimalValue>)) + ')';
and put the TxtValue in the cell. This will work.
Note: Please copy/paste the code because, the space here '( ' after the ( character is not a blank space.
Hope this helps.
Chn0 -
Hi chinoy -
I copied and pasted your code and it shows in excel as -5000 and it you just put it as '('+format(Netloss)+') it shows it as (-5000) and shows the - sign.0 -
-
Another possibility is inserting #,##0 ;[Red](#,##0);- value to the NumberFormat field in Excel Buffer. (Remove [Red] part if you do not require) This way it will format value using Excel Format Cells property.Ufuk Asci
Pargesoft0 -
Oh, okay it is new to me!
NumberFormat 0,00;(0,00) works too!0
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.6K Microsoft Dynamics NAV
- 18.7K NAV Three Tier
- 38.4K NAV/Navision Classic Client
- 3.6K Navision Attain
- 2.4K Navision Financials
- 116 Navision DOS
- 851 Navision e-Commerce
- 1K NAV Tips & Tricks
- 772 NAV Dutch speaking only
- 617 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 320 Dynamics CRM
- 111 Dynamics GP
- 10 Dynamics SL
- 1.5K Other
- 990 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 35 Design Patterns (General & Best Practices)
- 1 Architectural Patterns
- 10 Design Patterns
- 5 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1.1K General Chat
- 1.6K Website
- 83 Testing
- 1.2K Download section
- 23 How Tos section
- 252 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions