So basically, there is no such approach to create an excel file or CSV file using Apex. but, you can able to use XML DOM libraries to create a XML document which is excel friendly.
I hope this will help.
Want to become a Salesforce expert? Join salesforce apex training now!!
Want to know more about salesforce? Watch this video on Salesforce Developer Training for Beginners | Salesforce Administrator Training :