[英]How to insert checkbox in excel using openpyxl python ?
How to insert checkbox in excel using openpyxl python ? 如何使用openpyxl python在excel中插入复选框? By using pywin32 we can do the same using following lines of codes
通过使用pywin32,我们可以使用以下代码行来完成相同的操作
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 ? 但我想用openpyxl做什么?
To the best of my knowledge it's not possible to create new form controls such as checkboxes with openpyxl
. 据我所知,不可能使用
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. 但是,
openpyxl
允许您加载已包含表单控件的现有excel文件,修改excel文件中的数据,然后保存excel文件并保留表单控件。 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 ). 为此,您必须使用带有参数
keep_vba=True
openpyxl.load_workbook()
方法来加载现有的excel文件(请参阅此处 )。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.