Export to Excel function produces duplicate rows in the output spreadsheet