Export to Excel logic