Combine Excel Sheets in Java - Excel Files Merger

Microsoft Excel is one of the most popular Spreadsheet editors due to its multirole nature and huge stack of features. Suppose you have a huge number of Excel files and are looking to combine Excel files into one. GroupDocs.Merger provides Cloud SDKs and REST APIs to merge Excel files programmatically. So, you can automate the whole process by building an Excel file manager. Eventually, it will save time & effort and will give a competitive edge to your business software. In this blog post, we will learn how to combine Excel sheets in Java using GroupDocs.Merger Cloud SDK for Java.

The following points will be covered in this article:

Combine Excel Sheets - API Installation

The installation process of GroupDocs.Merger Cloud SDK for Java is super easy. There are two different ways you can install this library in your project. Therefore, you can download the JAR file or install it by using the following Maven configurations:

<repository>
    <id>groupdocs-artifact-repository</id>
    <name>GroupDocs Artifact Repository</name>
    <url>https://repository.groupdocs.cloud/repo</url>
</repository>
<dependency>
    <groupId>com.groupdocs</groupId
    <artifactId>groupdocs-merger-cloud</artifactId>
    <version>23.2</version>
    <scope>compile</scope>
</dependency>

Now, you will obtain the API credentials (Client ID, Client Secret) from the API Cloud dashboard which is again very simple and straight. In fact, you need a set of Client ID & Client Secret to make API calls to the Excel file merger API. However, please visit this guide in case you face any hassle.

Combine Excel Sheets in Java

You can merge multiple XLSX/XLS files into one file using GroupDocs.Merger Cloud SDK for Java. Since we have source files in our API Cloud dashboard, you can upload programmatically by invoking this UploadFile method or you can perform this action manually too.

The following steps demonstrate how to combine Excel sheets in Java:

  • Create an instance of the Configuration class and initialize it with Client ID and Client Secret.
  • Initialize an object of the DocumentApi class with the instance of the Configuration.
  • Instantiate an instance of the FileInfo class.
  • Invoke the setFilePath method to define the path of the first source file.
  • Create an instance of the JoinItem class and call the setFileInfo method.
  • Thus, call the setFilePath method to define the path of the second source file.
  • Create an instance of the JoinOptions class and invoke the setJoinItems method to define the output path of the resultant file.
  • Now, Instantiate an instance of the JoinRequest class with the object of the JoinOptions class.
  • The join function will combine Excel sheets into one.

You can copy and paste the following code snippet that is used to merge Excel files programmatically:

Once you run the main server file, you will see a merged file generated in the API cloud dashboard which you can download programmatically or manually.

You can see the output in the image below:

combine excel sheets

Merge Excel Files Online

In addition to a programmatic solution, there is an online tool to merge Excel files online. Above all, it is powered by GroupDocs.Merger Cloud SDK and it is a web-based tool. Moreover, it is free and asks for no account creation or subscription.

merge excel files online

Conclusion

We are ending this article here with the hope you have learned how to combine Excel files in Java using GroupDocs.Merger Cloud SDK for Java. In addition, we went through the code snippet and an online Excel files merger. You can visit the documentation and GitHub repo to explore it further. Please visit the Getting Started Guide to start the development. Lastly, feel free to interact with our live APIs here.

Finally, groupdocs.cloud is writing new articles. So, please stay in touch for the regular updates.

Help is Available

You can let us know about your questions or queries on our forum.

Frequently Asked Questions – FAQs

How to merge two Excel sheets in Java?

GroupDocs.Merger Cloud SDK for Java offers Cloud SDKs and REST APIs to merge Excel files programmatically. Please visit this link for further details.

Can I combine multiple Excel sheets into one?

You can use this online tool to merge Excel files online in a browser. It is free and is backed by GroupDocs.Merger Cloud SDK.

See Also