Java API to merge multiple Excel files into a file.
Java library to merge multi Excel files into a file.
Merge multiple Excel files into a file - Java REST API
API Request:
POST
https://api.aspose.cloud/v3.0/cells/merge
Merging multiple Excel files into a file is a complex task. Merging multiple Excel files into a file transitions is performed by our Java SDK while maintaining the source spreadsheet's main structural and logical content. Our Java library is a professional solution to merge multiple Excel files into a file online. This Cloud SDK gives Java developers powerful functionality and perfect API.
Code example in Java using REST API to merging multiple Excel files into a file
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.aspose.cloud.cells.api; | |
import com.aspose.cloud.cells.client.*; | |
import com.aspose.cloud.cells.model.*; | |
import com.aspose.cloud.cells.request.*; | |
import java.io.IOException; | |
import org.junit.Test; | |
import java.util.ArrayList; | |
import java.util.List; | |
import java.io.File; | |
import java.util.HashMap; | |
public class Example { | |
private CellsApi api; | |
public Example(){ | |
try { | |
api = new CellsApi( | |
System.getenv("CellsCloudClientId"), | |
System.getenv("CellsCloudClientSecret"), | |
"v3.0", | |
System.getenv("CellsCloudApiBaseUrl") | |
); | |
} catch (ApiException e) { | |
e.printStackTrace(); | |
} | |
} | |
public void Run(){ | |
try{ | |
String remoteFolder = "TestData/In"; | |
String AssemblyTestXlsx = "assemblytest.xlsx"; | |
String DataSourceXlsx = "datasource.xlsx"; | |
HashMap<String,File> fileMap = new HashMap<String,File>(); | |
fileMap.put(AssemblyTestXlsx , new File("D:\\TestData\\" + AssemblyTestXlsx)); | |
fileMap.put(DataSourceXlsx , new File("D:\\TestData\\" + DataSourceXlsx) ); | |
PostMergeRequest request = new PostMergeRequest(); | |
request.setFile(fileMap); | |
request.setFormat("png"); | |
request.setMergeToOneSheet(true); | |
request.setPassword(""); | |
request.setCheckExcelRestriction(true); | |
FilesResult response = api.postMerge(request); | |
} catch (ApiException e) { | |
e.printStackTrace(); | |
}catch (IOException e) { | |
e.printStackTrace(); | |
} | |
} | |
} |
How to use Java API to merge
- Create an account at Dashboard to get free API quota & authorization details
- Initialize CellsApi with Client Id, Client Secret, Base URL & API version
- Call postMerge method to get the resultant stream
System Requirements
- Maven 2.2.0 or newer
- Java(TM) SE Runtime Environment