Formatting Numbers with leading Zero to Text

2 posts, 0 answers
  1. Kevin
    Kevin avatar
    4 posts
    Member since:
    Nov 2014

    Posted 26 Nov 2015 Link to this post

    taking data from a db into the spreadsheet, and I have a column that is numbers, but they start with a zero (0123456789)

    When the data goes in it is ok, but any edits to the cells that also contain a zero ie 01234, will turn into 1234.

    How can I stop this from happening, as I require the leading zero to be there.

    I would think this would also apply to any new lines been added, I would need this been stopped also.


    Many thanks


  2. Nikolay Demirev
    Nikolay Demirev avatar
    136 posts

    Posted 30 Nov 2015 Link to this post

    Hi Kevin,

    You could set the number format for the cells or rows or columns you use to text. This can be achieved using the following code:
    this.radSpreadsheet.ActiveWorksheet.Columns[0, 1].SetFormat(new CellValueFormat("@"));

    Or some other number format that suits your needs here you can find more information on how to construct the format strings.

    Nikolay Demirev
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Back to Top