Skip to content

Instantly share code, notes, and snippets.

@aspose-com-kb
Last active February 8, 2026 10:00
Show Gist options
  • Select an option

  • Save aspose-com-kb/c946b371fd61c76036c5e79d37f27825 to your computer and use it in GitHub Desktop.

Select an option

Save aspose-com-kb/c946b371fd61c76036c5e79d37f27825 to your computer and use it in GitHub Desktop.
Merge Excel Files using Python. For more details: https://kb.aspose.com/cells/python/merge-excel-files-using-python/
import aspose.cells as ac
def combine_excels(excel_files, output_path, license_path="license.lic"):
# License
lic = ac.License()
lic.set_license(license_path)
# 1. Validate list of Excel files
if not excel_files:
print("No files to combine.")
return
# 2. Load the first workbook as the destination
combined_workbook = ac.Workbook(excel_files[0])
# 3. Combine remaining workbooks
for path in excel_files[1:]:
temp_workbook = ac.Workbook(path)
combined_workbook.combine(temp_workbook)
# 4. Save the combined workbook
combined_workbook.save(output_path)
print("Excel files combined successfully.")
if __name__ == "__main__":
excel_files = [
r"File1.xlsx",
r"File2.xlsx",
r"File3.xlsx",
r"File4.xlsx",
r"File5.xlsx",
r"File6.xlsx",
]
combine_excels(excel_files, r"CombinedOutput.xlsx", license_path=r"license.lic")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment