Posts: 4
Threads: 1
Joined: Jul 2021
When I delete lines through openpyxl, they are not deleted correctly. In some places they even stay. Need to delete rows completely, as excel does. Thank you.
import openpyxl
this_book = openpyxl.open( "example.xlsx" )
this_book.active = 1
def result_i():
return 10
i = result_i()
if i < 255:
this_book.active.delete_rows(i, 255-i)
this_book.save("result.xlsx")
this_book.close()
Example:
https://drive.google.com/file/d/1KINvDVn...sp=sharing
Posts: 8,144
Threads: 159
Joined: Sep 2016
Not sure what the problem is (i.e. what you consider problem). It works as expected - it's visible also from your [poor] screenshot. it removes line 10-254 and in the result line 10 is the former line 255. However it does not change the formulas in columns H:W (as expected)
Posts: 4
Threads: 1
Joined: Jul 2021
Jul-18-2021, 06:55 PM
(This post was last modified: Jul-18-2021, 06:55 PM by VladislavM.)
(Jul-18-2021, 03:20 PM)buran Wrote: Not sure what the problem is (i.e. what you consider problem). It works as expected - it's visible also from your [poor] screenshot. it removes line 10-254 and in the result line 10 is the former line 255. However it does not change the formulas in columns H:W (as expected)
Posts: 8,144
Threads: 159
Joined: Sep 2016
Jul-18-2021, 08:23 PM
(This post was last modified: Jul-18-2021, 08:24 PM by buran.)
Please, explain in writing exactly what the problem is.
As I said
(Jul-18-2021, 03:20 PM)buran Wrote: it removes line 10-254 and in the result line 10 is the former line 255. However it does not change the formulas in columns H:W (as expected)
Posts: 4
Threads: 1
Joined: Jul 2021
(Jul-18-2021, 08:23 PM)buran Wrote: Please, explain in writing exactly what the problem is.
As I said
(Jul-18-2021, 03:20 PM)buran Wrote: it removes line 10-254 and in the result line 10 is the former line 255. However it does not change the formulas in columns H:W (as expected)
The cell A2 doesnt make smaller, despite I'm using rows removal.
Posts: 8,144
Threads: 159
Joined: Sep 2016
Jul-19-2021, 05:19 AM
(This post was last modified: Jul-19-2021, 05:19 AM by buran.)
(Jul-18-2021, 08:36 PM)VladislavM Wrote: The cell A2 doesnt make smaller, despite I'm using rows removal. But you are deleting rows 10-254, why would that affect A2 or any of the rows 1-9???
VladislavM likes this post
Posts: 4
Threads: 1
Joined: Jul 2021
(Jul-19-2021, 05:19 AM)buran Wrote: (Jul-18-2021, 08:36 PM)VladislavM Wrote: The cell A2 doesnt make smaller, despite I'm using rows removal. But you are deleting rows 10-254, why would that affect A2 or any of the rows 1-9???
Because Microsof Office detele merged cell. I understand my wrong, thank you.
|