您可以将工作簿直接转换为字符串:
def get_worksheet_as_string workbook = RubyXL::Workbook.new # Fill workbook here or leave as is to download empty send_data workbook.stream.string, filename: "myworkbook.xlsx", disposition: 'attachment' end