1

I'm using win32com to write some dates that I receive from a database, and my problem is that I'm having values like '01' and in Excel is just '1' - not '01'. Example:

    b = row[1] # b has the value 01
    c = "-"+b+"-"  # c has value -01-
    sheet.Cells(1,1).Value = b  # I have in Excel '1' ; I've try with str(b), c - but is the same

How can I fix this, to have in Excel the value recognize as a String, in this case - 01?

Thanks.

1
  • Does sheet.Cells(1,1) have an attribute something like format where you can change it to string/text? Commented Oct 14, 2010 at 9:32

1 Answer 1

3

Thanks eumiro for the point

I've found the solution - I'm formating the cells to contain String values:

range = sheet.Range(sheet.Cells(1, 1), sheet.Cells(100, 2) )
range.NumberFormat = '@'

I'm doing this before I'm puting the values in cells and it works ok, now in Excel cells I have String values.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.