I have a requirement where I need to check if header/footer exists in an excel page. If yes, I need to remove them. To remove I used openpyxl package and manipulated in a way that i copied the contents of excel to a new sheet and deleted the master sheet[with header and footer].
But there may be a case where a page might not have a header or footer. However it doesn't matter. Still, is there any way to see if header or footer exists in excel
If you can do with a test that both the odd and even headers have empty texts, one hack using openpyxl could be to convert those to XML, then check that the result is empty:
def has_header_text(ws: Worksheet) -> bool:
return ws.oddHeader.to_tree('tag').text or ws.evenHeader.to_tree('tag').text