Home > other >  Xlwings delete rows of data in excel file
Xlwings delete rows of data in excel file

Time:09-26

As title, I use xlwings deleted files in the last line of data, the results showed that the content is to remove the program still read the last act null values, don't know what to do

CodePudding user response:

This is the code I delete data
 
# data reduction
Def m_button5OnButtonClick (self, event) :
Self. Sheet=self. The document. The sheets (' 2003 ')
Last_row=self. Sheet. Used_range. Rows. Count
Number=last_row - 2530
For I in range (number) :
Self. Content_delete (' A '+ STR (last_row))
Self. Content_delete (" B "+ STR (last_row))
Self. Content_delete (" C "+ STR (last_row))
Self. Content_delete (" D "+ STR (last_row))
Last_row=last_row - 1

Def content_delete (self, address) :
Self. Sheet. Range (address). The clear ()

CodePudding user response:

Has been resolved!!!!! Delete statements should write
 
# data reduction
Def m_button5OnButtonClick (self, event) :
Self. Sheet=self. The document. The sheets (' 2003 ')
Last_row=self. Sheet. Used_range. Rows. Count
Number=last_row - 2530
For I in range (number) :
Self. Content_delete (' A '+ STR (last_row))
# self. Content_delete (" B "+ STR (last_row))
# self. Content_delete (" C "+ STR (last_row))
# self. Content_delete (" D "+ STR (last_row))
Last_row=last_row - 1

Def content_delete (self, address) :
Self. Sheet. Range (address). API. EntireRow. Delete ()
  • Related