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 开发者_C百科the value recognize as a String, in this case - 01?
Thanks.
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.
精彩评论