Why so complicated?
Just TAB separate your columns and write the output to plain text file with an ".xls" extension?
That way, all you need to do is open the generated ".xls" file. Even though it's actually just a TAB-separated text file, Excel will open it and automatically treat each tab as a new column.
No idea why people still use csv files, frankly.