from ironxl import *
# Load the first Excel workbook
first_book = WorkBook.Load("sample.xlsx")
second_book = WorkBook.Create()
# Select the first worksheet in the workbook
worksheet = first_book.DefaultWorkSheet
# Duplicate the worksheet to the same workbook
worksheet.CopySheet("Copied Sheet")
# Duplicate the worksheet to another workbook with the specified name
worksheet.CopyTo(second_book, "Copied Sheet")
# Save changes in the first workbook
first_book.Save()
# Save the second workbook with the copied worksheet
second_book.SaveAs("copyExcelWorksheet.xlsx")複製 Excel 工作表


