Search code examples
excelxlrd

Get cell to show as string in excel


I have a cell which shows the following:

00002

This is a string identifier and not a number.

However, when I click on the cell, it treats it as a number. It says "2" in the text input at the top (next to the formula).

How would I convert this to be a string? If I do cell formatting as Text, it strips all the leading zeros and incorrectly turns it into "2". Right now it is formatted as a zip code.

How do I make it a string, such that I can grab the value "00002" using xlrd?


Solution

  • Is the cell set to a custom format of 00000 ? If so, you can convert it by using a formula:

    =TEXT(A1,"00000")
    

    Then copy -> paste-special -> values