Stewie Griffin
Stewie Griffin

Reputation: 14939

Is there a way of editing xlsx workbooks containing images in Python?

Is there a way to edit and save xlsx-workbooks that contain images, charts, figures etc. through Python?

A few things I've tried:

Related.

Upvotes: 3

Views: 982

Answers (1)

cdiggins
cdiggins

Reputation: 18203

The XLWings module seems to be the only module that supports this: http://docs.xlwings.org/en/stable/quickstart.html. Unlike other Python / Excel modules it seems to use COM automation under the hood to connect to 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']

Upvotes: 2

Related Questions