Battle 27: Rename Excel sheet name
Here is what I got from an Excel sheet name, there are some unexpected special characteristics. So I designed a simple method to resolve them.
First, we obtained the list of sheet name using the above method: xl = pd.ExcelFile(sFilename)
aSheet = xl.sheet_names
Then iterate the names and change the string: ss=openpyxl.load_workbook(sFilename) for sSheet in aSheet: sSheet_new = sSheet.replace(‘\xad’, ‘’) ss_sheet = ss[sSheet] ss_sheet.title = sSheet_new ss.save(sFilename) (The python indentation may have issue).
Some references: https://stackoverflow.com/questions/39540789/how-to-rename-the-sheet-name-in-the-spread-sheet-using-python