简体   繁体   中英

How to insert checkbox in excel using openpyxl python ?

How to insert checkbox in excel using openpyxl python ? By using pywin32 we can do the same using following lines of codes

cb = sheet.CheckBoxes().Add(Left=sheet.Cells(row,column).Left, 
                            Top=sheet.Cells(row,column).Top, 
                            Width=sheet.Cells(row,column).Width, 
                            Height=sheet.Cells(row,column).Height)
cb.Caption = name_of_checkbox

but i want to do using openpyxl ?

To the best of my knowledge it's not possible to create new form controls such as checkboxes with openpyxl .

However openpyxl does allow you to load an existing excel file that already contains form controls, modify the data in the excel file, and then save the excel file with preservation of the form controls. For this to work you must use the method openpyxl.load_workbook() with parameter keep_vba=True to load the existing excel file (see here ).

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