Need to output data to an Excel-compatible file -- but don't need to do any formatting of the resulting worksheet? You could simply write the data to a tab-delimited text file and give it the ".xls" filename extension...
# where recordset is a database recordset,
# array of arrays, etc:
xls = open('worksheet.xls', 'w')
recordset.each do |row|
There are, of course, several alternatives involving CSV, XML, or WIN32OLE. Sometimes I will output the data to a tab-delimited text file, then use WIN32OLE to open the file in Excel, apply formatting, and then save in native Excel format...
xl = WIN32OLE.new('Excel.Application')
wb = xl.Workbooks.Open('worksheet.xls')
# insert formatting code here...
xl.DisplayAlerts = 0
xl.DisplayAlerts = 1
This is often much faster than writing the data directly to a new Excel workbook via WIN32OLE.