Uncategorized

xlwings; Python: Numbers transfered to Excel sheet are transfered without a comma


Im trying to write numbers I pulled from Origin Pro to an excel sheet using xlwings.
Two of three numbers are not transfered correctly, without a comma so they become huge.
Mysteriously one is taken correctly with the comma at the right place. I can’t figure out why this is, maybe someone has an idea. When I use the print() function in python they are displayed correctly in the console of my visual studio code tab…
In the first row of the table I added, the numbers are supposed to be: 23,1381…;0,99916….;6204,8816…

enter image description here

Thanks in advance!

best regards

wb_name = "M11+P32TRIAL.xlsx"
sheet_name = "Gauss"
df_mapping = {"D32" : dfAK, "G32" : dfAK1, "J32" : dfAK2}

#open excel in the background

with xw.App(visible=False) as app:
    wb = app.books.open(wb_name)

    #add sheet if it does not exist
    current_sheets = [sheet.name for sheet in wb.sheets]
    if sheet_name not in current_sheets:
        wb.sheets.add(sheet_name)

    #write dataframe to cell range
    for cell_target, df in df_mapping.items():
        wb.sheets(sheet_name).range(cell_target).options(pd.DataFrame, index = False).value = df

Thats the part where I use xlwings, don’t think that is helpful though

Maybe the values from the Origin Pro data I pulled where displayed in a different format so I checked but it was the same in the table



Source link

Leave a Reply

Your email address will not be published. Required fields are marked *