Copied excel cell values do not take percentage value when printed in another

659 Views Asked by At

I am facing prob while copying cell value from excel and printing it to another excel does not take percentage value.

like I have excel where cell values are like:

| 22.13% | 22.10% | 23.34% |

Now while copying the cell values and printing them in another excel it is showing :

| .221 | .221 | .233 |   

m=1
for rownum in range(1,sheetIO.nrows):
    data = [str(sheetIO.cell_value(rownum, col)) for col in range(sheetIO.ncols)] ## here is the prob it is calculating and taking the value
    if data[1]== '':
        newDataArr = data[0].replace (" ", "_")
    else:
        k=1
        if data[0] in header_series:
            dataNew = newDataArr+'_'+str(data[0])                    
            sheet1.write(m, 0, dataNew)
            for r in range(1,len(data)):
                sheet1.write(m, k, str(data[r]))
                k+=1
            m+=1

Thanks in advance

1

There are 1 best solutions below

1
On
    sheet1.write(m, k, str(data[r]),easyxf(num_format_str='0.00%'))

The 4 th argument in write() function takes an object of XFstyle(eXtended Formatting) type, which are best set up using easyxf() function. For more details refer to formatting section of http://xlwt.readthedocs.io/en/latest/api.html