gpt4 book ai didi

python - 有没有办法在 Python 中编辑包含图像的 xlsx 工作簿?

转载 作者:可可西里 更新时间:2023-11-01 10:32:39 26 4
gpt4 key购买 nike

有没有一种方法可以通过 Python 编辑和保存包含图像、图表、图形等的 xlsx-workbook?

我尝试过的一些事情:

  • > openpyxl :

    openpyxl does currently not read all possible items in an Excel file so images and charts will be lost from existing files if they are opened and saved with the same name.

  • > xlwt :

    xlwt is a library for writing data and formatting information to older Excel files (ie: .xls)

  • > xlutils :

    Utilities for working with Excel files that require both xlrd and xlwt

<子> Related.

最佳答案

XLWings 模块似乎是唯一支持此功能的模块: http://docs.xlwings.org/en/stable/quickstart.html .与其他 Python/Excel 模块不同,它似乎在后台使用 COM 自动化来连接到 Excel。

import xlwings as xw
wb = xw.Book() # this will create a new workbook
wb = xw.Book('FileName.xlsx') # connect to an existing file in the current working directory
wb = xw.Book(r'C:\path\to\file.xlsx') # on Windows: use raw strings to escape backslashes
app = xw.App() # or something like xw.apps[0] for existing apps
wb = app.books['Book1']

关于python - 有没有办法在 Python 中编辑包含图像的 xlsx 工作簿?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46153613/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com