简体   繁体   中英

Python OpenPyxl

I'm working with a large excel file(30MB+,xlsm). Many of them contain photos in cell comments, so this file takes up so much space. First im open a file to read and get specific column name. Im open that with:

self.wb = load_workbook(str(self.directory[0]), read_only=True, keep_vba=True, data_only=False)
self.ws = self.wb['BAZA_PRACOWNIKOW']
self.sheet = self.wb.active

After finding the appropriate cells, I open it again to add the relevant data to it:

self.wb = load_workbook(str(self.directory[0]), read_only=False, keep_vba=True, data_only=False)
self.ws = self.wb['BAZA_PRACOWNIKOW']
self.sheet = self.wb.active

When I complete this file I would like to save it, so:

self.wb.save('new.xlsm')

After that i got an error:

D:\\Anaconda\\lib\\site-packages\\openpyxl\\reader\\worksheet.py:310: UserWarning: Data Validation extension is not supported and will be removed warn(msg) The file size after saving decrease to 8mb. All photos in comments are not in new.xlsm file. Can someone help me ?

http://openpyxl.readthedocs.io/en/latest/usage.html

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.

Try lxlm or xlwings maybe?

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