Is it possible?
I know ws.set_row('B:B', options={'hidden': True})
But, is there something like ws.set_row('B:B', options={'delete_row': True})
?
Python Delete Excel Rows and Columns In openpyxl, we can use delete_rows() and delete_cols() methods from the Worksheet object to remove entire rows and columns. The syntax is straightforward: delete_rows(row_id, number_of_rows)
To delete an entire row in Excel using VBA, you need to use the EntireRow. Delete method. The above code first specifies the row that needs to be deleted (which is done by specifying the number in bracket) and then uses the EntireRow. Delete method to delete it.
To quote the Worksheet
docs:
"""
The options parameter is a dictionary with the following possible keys:
'hidden'
'level'
'collapsed'
""""
Other values like delete_row
are not acceptable.
It doesn't seem possible to do what you ask. Probably the best approach remains the one proposed in this old post.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With