spreadsheet_file = StringIO.new data.write(spreadsheet_file) attachments['HelloWorld.xls'] = spreadsheet_file.read