Page_DataRendering conditional $header

I’ve added some text as $header, on Page_DataRendering and it displays perfectly on the list view.
The problem is it also appears when I export the list to csv.
How can I hide it there?
Thanks in advance

You may check if IsExport() before you set your $header.