As Richard said, you are not making a 'ToCSV' document in your code. It looks like you are trying to make an actual .xlsx file. You can't do it that way. If you follow Richard's advice you can make a .csv file that will open correctly in excel. This is usually sufficient for most needs.
However if you really want to create a real xlsx file you will need a lot more work.
Here's a link to give you some idea of what you are looking at.
How to Read and Write .xlsx (Excel 2007) file - Part I[
^]