You will have to build the spreadsheet string line by line; decide what you want in each cell, extract the cell data from the cluster, convert it to a string (number to string functions etc..) and concatinate it with the data for the next cell, but with formatting characters in between (e.g. tab to separate each element on the same row (i.e. columns) and carriage return line feed to separate rows..
You can either build the entire spreadsheet in memory and then write it to disk using e.g. write characters...or you can open/create a file first and write one line at a time with the write function and then close it afterwards (use the basic file io functions so that the file is not opened and closed for each iteration, that makes it very slow).
I have attached a
small example.