Openpyxl删除单元格/清除内容

我正在寻找删除或清除某些单元格内容的方法。 search之后,似乎使用openpyxl并不是一件简单的事情。 发现这个类似的问题 ,build议将单元格设置为无。 我这样做了,但是当我尝试附加数据时,它仍然将其追加到我设置为None的所有行的末尾。

def clear_sheet(this_sheet): ''' Clear all cells starting from third row. we keep our header and replaces other rows content by None ''' dst_wb=openpyxl.load_workbook(dest_filename, read_only=False, keep_vba=True) dst_ws=dst_wb.get_sheet_by_name(this_sheet) #We kee the header located in row 2, and set the rest to None if dst_ws.cell('A3').value is not None: #check if already cleared content for row in dst_ws.iter_rows(row_offset=2): for cell in row: cell.value=None dst_wb.save(dest_filename) def copy_data(searchMilestone): ''' gets data from the sequence file ''' dst_wb=openpyxl.load_workbook(dest_filename, read_only=False, keep_vba=True) dst_ws=dst_wb.get_sheet_by_name(sequence_sheet) data =[] print dst_ws.max_row #here should return 3, but it seems it is counting all the cells we set to None for i in xrange(sequenceWs.nrows): #this reading part is done using xlrd module milestone=sequenceWs.cell(i,1).value execution=sequenceWs.cell(i,2).value system=sequenceWs.cell(i,16).value if searchMilestone in milestone and 'WC' in execution: #copy some data line=[data, data, data] dst_ws.append(line) dst_wb.save(dest_filename) 

在我写入数据的工作簿中,我冻结了窗格和一些filter(显示所有数据)。 清除内容后,如何强制从第3行追加任何build议? 我使用python 2.7和openpyxl 2.3。