SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


How to stop Excel deleting leading zeros(SSRS -> Excel load)


How to stop Excel deleting leading zeros(SSRS -> Excel load)

Author
Message
Saintmount.Sql
Saintmount.Sql
SSC Veteran
SSC Veteran (211 reputation)SSC Veteran (211 reputation)SSC Veteran (211 reputation)SSC Veteran (211 reputation)SSC Veteran (211 reputation)SSC Veteran (211 reputation)SSC Veteran (211 reputation)SSC Veteran (211 reputation)

Group: General Forum Members
Points: 211 Visits: 507
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
Lowell
Lowell
SSC Guru
SSC Guru (73K reputation)SSC Guru (73K reputation)SSC Guru (73K reputation)SSC Guru (73K reputation)SSC Guru (73K reputation)SSC Guru (73K reputation)SSC Guru (73K reputation)SSC Guru (73K reputation)

Group: General Forum Members
Points: 73907 Visits: 40974
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
--help us help you! If you post a question, make sure you include a CREATE TABLE... statement and INSERT INTO... statement into that table to give the volunteers here representative data. with your description of the problem, we can provide a tested, verifiable solution to your question! asking the question the right way gets you a tested answer the fastest way possible!
Saintmount.Sql
Saintmount.Sql
SSC Veteran
SSC Veteran (211 reputation)SSC Veteran (211 reputation)SSC Veteran (211 reputation)SSC Veteran (211 reputation)SSC Veteran (211 reputation)SSC Veteran (211 reputation)SSC Veteran (211 reputation)SSC Veteran (211 reputation)

Group: General Forum Members
Points: 211 Visits: 507
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
mikehunsaker
mikehunsaker
Valued Member
Valued Member (52 reputation)Valued Member (52 reputation)Valued Member (52 reputation)Valued Member (52 reputation)Valued Member (52 reputation)Valued Member (52 reputation)Valued Member (52 reputation)Valued Member (52 reputation)

Group: General Forum Members
Points: 52 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
Koen Verbeeck
Koen Verbeeck
SSC Guru
SSC Guru (63K reputation)SSC Guru (63K reputation)SSC Guru (63K reputation)SSC Guru (63K reputation)SSC Guru (63K reputation)SSC Guru (63K reputation)SSC Guru (63K reputation)SSC Guru (63K reputation)

Group: General Forum Members
Points: 63966 Visits: 13298
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?
My blog at SQLKover.

MCSE Business Intelligence - Microsoft Data Platform MVP
mikehunsaker
mikehunsaker
Valued Member
Valued Member (52 reputation)Valued Member (52 reputation)Valued Member (52 reputation)Valued Member (52 reputation)Valued Member (52 reputation)Valued Member (52 reputation)Valued Member (52 reputation)Valued Member (52 reputation)

Group: General Forum Members
Points: 52 Visits: 180
Hey J -

Just curious... how did you solve this?

Mike
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search