简体   繁体   English

如何使用openpyxl python在excel中插入复选框?

[英]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.

相关问题 在 Python 中使用 openpyxl 将行插入 Excel 电子表格 - Insert row into Excel spreadsheet using openpyxl in Python Python使用openpyxl操纵Excel - Python using openpyxl manipulate Excel 如何在python中使用openpyxl从Excel获取浮点值? - How to get float value from excel using openpyxl in python? 如何使用python的openpyxl在Excel上绘制带有日期格式的折线图 - how to draw line chart with date fomat on excel using openpyxl of python 如何解决“ ValueError:无法转换为Excel”? (使用Python和openpyxl) - How to solve “ValueError: Cannot convert to Excel”? (Using Python & openpyxl) 在 Excel 文件中,如何使用 openpyxl (Python) 查找单元格的背景颜色 - In a Excel file how to find the background color of a cell using openpyxl (Python) 如何在 Python 中使用 Openpyxl 对多行的 excel 行进行平均? - How to average across excel rows for multiple rows using Openpyxl in Python? 如何使用 openpyxl 和 python 在 excel 中写入多张工作表(带 SHEETNAMES) - How to write multiple sheets(WITH SHEETNAMES) in excel using openpyxl and python 如何使用 python openpyxl 从 excel 中按列名删除列 - how to delete columns by column name from an excel using python openpyxl Openpyxl:使用 Python 时如何删除 excel 公式中出现的“@”符号 - Openpyxl: How to remove the '@' symbol appearing in excel formulae when using Python
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM