小编And*_* Do的帖子

win32com Excel.Application 无法再打开文档

这上周还可以,但由于某种原因今天停止工作了,也许是因为新年?

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)

有人可以帮忙吗?

谢谢!

python excel win32com

4
推荐指数
1
解决办法
4万
查看次数

如何使 Pandas 中的所有非日期值都为空

我有一个 excel 文档,其中用户将日期和字符串放在同一列中。我想让每个字符串对象为空并保留所有日期。我如何在熊猫中做到这一点?谢谢。

python pandas

2
推荐指数
1
解决办法
1200
查看次数

标签 统计

python ×2

excel ×1

pandas ×1

win32com ×1