Writing a Excel file to Sharepoint site

We have created Sharepoint add-in and given write permission to a site/folder. I have a pipline that allows me to write a text file or a csv to the sharepoint and i can open them in sharepoint, but if i write a excel file it does show up in sharepoint but i am not able to open it, it say the file is corrupted.

Appreciate any help.

Nevermind,the Excel file needs to be in byte array format