这上周还可以,但由于某种原因今天停止工作了,也许是因为新年?
def remove_strikethroughs(xlsx):
excel = win32com.client.Dispatch('Excel.Application')
xl = pd.ExcelFile(xlsx)
sheet_names = xl.sheet_names
for sheet in sheet_names:
if any(tab in sheet for tab in tabs_used):
#print (sheet)
wb = excel.Workbooks.Open(xlsx)
ws = wb.WorkSheets(sheet)
for cell in ws.Range('A5:B150'):
if cell.Font.Strikethrough == True:
cell.value = '[MDU]' + str(cell)
wb.Save()
wb.Close()
excel.Visible = True
excel.DisplayAlerts = True
excel.Application.Quit()
Run Code Online (Sandbox Code Playgroud)
我收到以下错误消息:
"AttributeError: '<win32com.gen_py.Microsoft Excel 15.0 Object Library.Workbooks instance at 0x20920640>' object has no attribute 'open'"
Run Code Online (Sandbox Code Playgroud)
有人可以帮忙吗?
谢谢!
我有一个 excel 文档,其中用户将日期和字符串放在同一列中。我想让每个字符串对象为空并保留所有日期。我如何在熊猫中做到这一点?谢谢。