Python to delete a row in excel spreadsheet

前端 未结 6 633
走了就别回头了
走了就别回头了 2021-01-20 03:21

I have a really large excel file and i need to delete about 20,000 rows, contingent on meeting a simple condition and excel won\'t let me delete such a complex range when us

6条回答
  •  星月不相逢
    2021-01-20 03:54

    You can use,

    sh.Range(sh.Cells(1,1),sh.Cells(20000,1)).EntireRow.Delete()
    

    will delete rows 1 to 20,000 in an open Excel spreadsheet so,

    if sh.Cells(1,1).Value == 'X':
    
       sh.Cells(1,1).EntireRow.Delete()
    

提交回复
热议问题