• Do you have to export to excel? Can you not export to another format, CSV, txt etc?

    If it has to be xlsx then you will need to export 1 million rows into 1 sheet, then export the next 1 million rows to another sheet etc etc until all rows are exported.

    What is the reasoning behind what you are trying to do? What is the expected outcome? Maybe there is a better way to do what you are trying to do.