简体   繁体   中英

xlwings book open excel workbook but change the file name to lowercase

I used xlwings to open excel workbook. It worked fine up to last month. But today, when I run the same code, it opened my worksheet but convert my worksheet name into lowercase.

Anybody know why is that? And how can I keep my original captalization?

I am using windows 10.

Example, when I run below code, the ABC.xlsx automatically converted abc.xlsx by xlwings.

import xlwings as xw

fullPath = ''\\\\xxx\\xxx\\ABC.xlsx'
psw = '123'
wb = xw.Book(fullPath, password = psw)

I had the same issue and I am not sure why it does that (I think it only happens to protected workbooks). An easy fix is renaming the file again as follows:

import os
old_file_name = os.path.split(fullPath)[0] +'\\' + os.path.split(fullPath)[1].lower() 
new_file_name = fullPath
os.rename(old_file_name, new_file_name)

This code assumes that your path and file are saved under fullPath.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM