excel = WIN32OLE.new 'Excel.Application' excel.visible = true workbook = excel.Workbooks.open "path/to/file" sheet = workbook.Worksheets 1 def excel_copy_and_paste_last_row excel, workbook, sheet last_row = sheet.UsedRange.Rows.Count sheet.Rows(last_row).copy sheet.Cells(last_row + 1, 1).Select workbook.ActiveSheet.Paste excel.CutCopyMode = false end def excel_save_and_close excel, workbook # save xlsx workbook.Saved = true workbook.Save # close excel excel.activeworkbook.close 0 excel.quit end