Problems with creating CSV or excel

Please use the below guide to post code in preformatted text, so that it is easy to copy your code.

howtopastecode