Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

How to stop Excel deleting leading zeros(SSRS -> Excel load) Expand / Collapse
Author
Message
Posted Tuesday, March 5, 2013 2:11 PM
SSC Rookie

SSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC Rookie

Group: General Forum Members
Last Login: Friday, August 23, 2013 7:58 AM
Points: 43, Visits: 506
HI,
I've few issues after exporting the SSRS report to Excel Mode.

How do i stop Excel from deleting leading zeros permanently and not having to change the number type.

While clicking Excel cel,. value changed to 123 from 00123. How do prevent the change of value (00123 -> 123)

Also is there a way to stop Excel from change long numbers eg. 321312321303 to 3.21E+10.

Thanks,
J
Post #1427037
Posted Tuesday, March 5, 2013 2:41 PM


SSChampion

SSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampion

Group: General Forum Members
Last Login: Today @ 2:08 PM
Points: 12,903, Visits: 31,972
excel automatically treats anything that looks like a number as a number, dates as dates, etc
I believe you'd have to change you report of the data to explicitly place a single quote in the field, which is how Excel knows to override the behavior and treat the value as text...
that's annoying, because you have to do something like this:
SELECT
'''' + TheCode As TheCode,
'''' + '00123' As TheValue,
'''' + CONVERT(VARCHAR,321312321303) As TheDecimal
FROM YourTable



Lowell

--There is no spoon, and there's no default ORDER BY in sql server either.
Actually, Common Sense is so rare, it should be considered a Superpower. --my son
Post #1427043
Posted Tuesday, March 5, 2013 3:22 PM
SSC Rookie

SSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC Rookie

Group: General Forum Members
Last Login: Friday, August 23, 2013 7:58 AM
Points: 43, Visits: 506
Thanks, when I use this option, Excel values are precedes with ' code.
Is any work around to remove the ' code in reporting side.

Ty
J
Post #1427057
Posted Wednesday, March 20, 2013 6:25 AM
SSC Rookie

SSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC Rookie

Group: General Forum Members
Last Login: Friday, January 17, 2014 11:31 AM
Points: 26, Visits: 180
I've had this problem for years with web application development. Adding a single apostrophe (') is the best option. Unfortunately, Excel will always attempt to format the data based on the value. Anything that looks like a number will automatically be formatted as a number; anything that looks like a date will be formatted like a date; etc... You will have to add a symbol (apostrophe, dash, etc...) in front of the number so that Excel thinks the value is plain text.

The option that I use is to do nothing. If the spreadsheet is going to an end-user, I make sure they understand how to format the data. So they manually format the column to show the leading zeros. The reason that I went with this option is for calculation purposes. If the end-user needs to perform a calculation on the values, it's very difficult when the value has a leading symbol. However, if you do not need to perform a calculation on the value, adding a leading symbol might be your best option.

HTH.

Mike
Post #1433168
Posted Wednesday, March 20, 2013 3:57 PM


SSChampion

SSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampion

Group: General Forum Members
Last Login: Today @ 7:45 AM
Points: 13,538, Visits: 10,412
Saintmount.Sql (3/5/2013)
Thanks, when I use this option, Excel values are precedes with ' code.
Is any work around to remove the ' code in reporting side.

Ty
J


If time is on your side you could create expressions based on the rendering format.

Conditional report rendering based on render formats for SSRS Reports




How to post forum questions.
Need an answer? No, you need a question.
What’s the deal with Excel & SSIS?

Member of LinkedIn. My blog at LessThanDot.

MCSA SQL Server 2012 - MCSE Business Intelligence
Post #1433530
Posted Tuesday, March 26, 2013 6:53 AM
SSC Rookie

SSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC Rookie

Group: General Forum Members
Last Login: Friday, January 17, 2014 11:31 AM
Points: 26, Visits: 180
Hey J -

Just curious... how did you solve this?

Mike
Post #1435447
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse