Seal Report Forum
»
Report Edition
»
Reports
»
example of cell script to format numeric with 2 decimals?
Rank: Member
Groups: Registered
Joined: 10/23/2019(UTC) Posts: 11 
|
Hello,
I have a calculated field displaying as a numeric, with occurrences like 9.999999997 I'd like to always have 2 decimals. From what I learned in this forum, the best way to do this is using the cell script for this field.
But I can't seem to get the syntax right. Can someone show me how I can reformat the output to a 2 decimal numeric please?
Thanks a lot, Tom
|
|
|
|
Rank: Member
Groups: Registered
Joined: 10/23/2019(UTC) Posts: 11 
|
Hello,
I've found the answer myself, so for everything else who needs this:
cell.Value = (Convert.ToDouble(cell.Value)).ToString("#.##");
|
|
|
|
Rank: Administration
Groups: Administrators
Joined: 12/20/2013(UTC) Posts: 1,209  Thanks: 14 times Was thanked: 206 time(s) in 199 post(s)
|
Normally you do not need to use CellScript... Just set the 'Format' property to 'Numeric 2 Decimals'
|
|
|
|
Rank: Member
Groups: Registered
Joined: 10/23/2019(UTC) Posts: 11 
|
Thanks,
This does not seem to work when using excel files for a source.
|
|
|
|
Rank: Administration
Groups: Administrators
Joined: 12/20/2013(UTC) Posts: 1,209  Thanks: 14 times Was thanked: 206 time(s) in 199 post(s)
|
probably because some cells have text in the Excel sheet, so the ODBC driver returns the data as text instead of numeric...
|
|
|
|
Seal Report Forum
»
Report Edition
»
Reports
»
example of cell script to format numeric with 2 decimals?
Forum Jump
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.