GroupDocs.Merger for Python via .NET allows you to combine multiple Excel spreadsheets into a single file programmatically. All worksheets, data, formulas, charts, and formatting are preserved — no Microsoft Excel or third-party software required.
Spreadsheet files store data in rows and columns and are saved in formats such as XLSX (Microsoft Excel Open XML Spreadsheet), XLS (Microsoft Excel Binary File Format), and ODS (OpenDocument Spreadsheet). XLSX is the default format introduced with Microsoft Office 2007, based on the Open Packaging Conventions (OOXML/ECMA-376 standard).
Steps to merge XLSX files
Create an instance of the Merger class and pass the path to the first (base) XLSX file.
Call merger.join() with the path to each additional XLSX file to append.
Call merger.save() with the desired output path to write the merged file.
fromgroupdocs.mergerimportMergerdefmerge_excel_documents():# Load the first document as the merge basewithMerger("./input.xlsx")asmerger:# Append the second Excel spreadsheetmerger.join("./input2.xlsx")# Save the combined documentmerger.save("./output.xlsx")if__name__=="__main__":merge_excel_documents()
input.xlsx is a sample file used in this example. Click here to download it.
input2.xlsx is a sample file used in this example. Click here to download it.