How to clear a range of values in an Excel workbook using OpenPyXl

后端 未结 4 1964
佛祖请我去吃肉
佛祖请我去吃肉 2021-01-01 18:14

I have a workbook that I would like to clear a range of values with using OpenPyXI. So far I have the following:

# Import OpenPyXl module.
from openpyxl impo         


        
4条回答
  •  醉梦人生
    2021-01-01 18:54

    It seems that the library doesn't have a method to clear or set a range directly. So your best chance is probably to clear the value for each cell:

    for row in ws['A1:G37']:
      for cell in row:
        cell.value = None
    

提交回复
热议问题