Python + xlwings:'pywintypes.com_error:(-2147467262,'不支持这种接口',无,无)'

时间:2018-11-17 22:17:28

标签: python excel python-3.x tkinter xlwings

我已经编写了一些适用于第一次迭代的代码,但随后吐出了错误消息:

pywintypes.com_error: (-2147467262, 'No such interface supported', None, None)

IDE特别突出显示该行     project_sheet.range('J17')。options(numbers = int).value = 2018

以下代码的

。在使用xlwings和python的过程中,我从来没有遇到过这样的消息,有人知道这是怎么回事?

def xl_vba(self, aop_src, aop_dst, gsrp_src, prod_src, year_of_int):

    xw.App(visible=False)
    # initialize row offsets
    file_list = os.listdir('%s' % aop_src)
    os.chdir((aop_src))
    for file in (file_list[excel_file_index:]):
        if file.endswith(".xlsx") and ("AOP" in file):
            current_book = xw.Book(file)
            if "Combined" not in file:
                project_sheet = current_book.sheets[1]
            else:
                for sheet in current_book.sheets:
                    if "Project" in current_book[sheet].name:
                        project_sheet = current_book[sheet]

            # Set Year of Interest
            project_sheet.range('J17').options(numbers=int).value = 2018

            ...

            file_name = project_code + str(asset_id) + "-" + project_name + "-" + "AOP" + "-" + str(current_date) + ".xlsx"

            current_book.save('%s\%s' % (aop_dst, file_name))
            current_book.close()

        excel_file_index += 1

我认为这与'current_book.save()'的工作方式以及我的使用方式有关,因为在不保存excel书的情况下,迭代过程一直进行到最终文件为止,但是我不知道如何制作这行得通。

0 个答案:

没有答案
相关问题