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

  • 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

  • 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!

  • 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

  • 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

  • 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[/url]

    Need an answer? No, you need a question
    My blog at https://sqlkover.com.
    MCSE Business Intelligence - Microsoft Data Platform MVP

  • Hey J -

    Just curious... how did you solve this?

    Mike

Viewing 6 posts - 1 through 5 (of 5 total)

You must be logged in to reply to this topic. Login to reply