Merge Multiple Excel Files into One using REST API in Python.

You may need to merge multiple Microsoft Excel files into one file programmatically. By combining Excel files together, you can easily generate reports based on the data available in multiple Excel files. As a Python developer, you can merge two or more Excel workbooks or spreadsheets from different files into a single workbook. In this article, you will learn how to merge multiple Excel files into one file using a REST API in Python.

The following topics shall be covered in this article:

Excel Merger REST API and Python SDK

For merging multiple XLSX files, I will be using the Python SDK of GroupDocs.Merger Cloud API. It allows you to combine, split, remove and rearrange a single page or a collection of pages from supported document formats of Word, Excel, PowerPoint, Visio drawings, PDF, and HTML.

You can install GroupDocs.Merger Cloud to your Python application using the following command in the console:

pip install groupdocs-merger-cloud

Please get your Client ID and Secret from the dashboard before following the mentioned steps. Once you have your ID and secret, add in the code as shown below:

Merge Multiple Excel Files using REST API in Python

You can combine two or more Excel files programmatically on the cloud by following the steps mentioned below:

  • Upload the Excel files to the Cloud
  • Merge Multiple Excel files using Python
  • Download the merged file

Upload the Excel Files

Firstly, upload the Excel files to the Cloud using the code example given below:

As a result, the uploaded XLSX files will be available in the files section of your dashboard on the cloud.

Merge Multiple Excel Files using Python

You can easily merge multiple Excel files into a single file programmatically by following the steps mentioned below:

  • Create an instance of the DocumentApi
  • Create the first JoinItem
  • Provide the input file path for first JoinItem in the FileInfo
  • Create the second JoinItem
  • Provide the input file path for second JoinItem in the FileInfo
  • Optionally, repeat the above steps to add more files
  • Create the JoinOptions
  • Add comma separated list of created join items
  • Set the output file path
  • Create the JoinRequest with JoinOptions
  • Call the join() method with JoinRequest

The following code sample shows how to merge multiple Excel files using a REST API in Python.

Merge Multiple Excel Files using REST API in Python

Merge Multiple Excel Files using REST API in Python

Download the Merged File

The above code sample will save the merged Excel file on the cloud. You can download it using the following code sample:

Merge Specific Excel Sheets using Python

You can easily merge specific Excel sheets from multiple Excel files into a single file programmatically by following the steps mentioned below:

  • Create an instance of the DocumentApi
  • Create the first JoinItem
  • Provide the input file path for first JoinItem in the FileInfo
  • Create the second JoinItem
  • Provide the input file path for second JoinItem in the FileInfo
  • Define start sheet number and end sheet number for the second JoinItem
  • Optionally, define the range mode
  • Create the JoinOptions
  • Add comma separated list of created join items
  • Set the output file path
  • Create the JoinRequest with JoinOptions
  • Get results by calling the join() method of the DocumentAPI

The following code snippet shows how to merge specific Excel sheets from multiple files using a REST API in Python.

Merge Specific Excel Sheets using Python

Merge Specific Excel Sheets using Python

Try Online

Please try the following free online XLSX merging tool, which is developed using the above API. https://products.groupdocs.app/merger/xlsx

Conclusion

In this article, you have learned how to merge multiple Excel files on the cloud. Moreover, you have seen how to merge specific Excel sheets from multiple files into one file using a REST API in Python. This article also explained how to programmatically upload XLSX files to the cloud and then download the merged file from the Cloud. The API also enables you to reorder or replace document pages, change page orientation, manage document passwords and perform other manipulations easily for any supported file format. You can learn more about GroupDocs.Merge Cloud API using the documentation. We also provide an API Reference section that lets you visualize and interact with our APIs directly through the browser. In case of any ambiguity, please feel free to contact us on the forum.

See Also