简体   繁体   中英

How can I add and modify shapes in an Excel file using Python

Does anyone know a way of getting around the fact that shapes are not supported in openpyxl ?

Is there a different library or code that I can use to achieve this??

I tried manipulating an excel file that had shapes and when my app saved the file, the shapes were gone.

Try xlwings library. It has the ability to add and modify shapes.

For example:

import xlwings as xw


wb = xw.Book('example.xlsx')
sht = wb.sheets[0]
sht.shapes.add_shape(1, 1, 2, 2, 'circle')
wb.save()

More information here https://docs.xlwings.org/en/stable/api.html#shapes

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM