How to Merge Cells in an Excel Worksheet – Aspose.Cells Cloud API (v3.0)

API version: v3.0 (last verified 2024‑09)

The Aspose.Cells Cloud REST API merges a rectangular block of cells into a single cell that spans the specified rows and columns.

Prerequisites

  • A valid Aspose Cloud subscription.
  • An Excel workbook stored in Aspose Cloud storage (or a public URL).
  • Supported Excel formats: .xlsx, .xls, .xlsm, etc.

Authentication

All requests must include a Bearer JWT token in the Authorization header.

  1. Generate a token by sending a POST request to the OAuth 2.0 token endpoint with your client ID and secret.
  2. Use the returned token in subsequent API calls:
-H "Authorization: Bearer <jwt token>"

Refer to the Authentication guide for detailed steps.

How‑to Merge Cells (quick summary)

  1. Set up authentication – obtain a JWT token.
  2. Build the request URL with the workbook name, worksheet name, and merge parameters (startRow, startColumn, totalRows, totalColumns).
  3. Send a POST request to the merge endpoint.
  4. Check the response – a 200 status indicates success; otherwise handle the error codes listed below.

REST API

POST http://api.aspose.cloud/v3.0/cells/{name}/worksheets/{sheetName}/cells/merge

The request parameters are:

Name Type Location Description
name string path The workbook name.
sheetName string path The worksheet name.
startRow integer query Zero‑based index of the first row (0 = first row).
startColumn integer query Zero‑based index of the first column (0 = first column).
totalRows integer query Number of rows to merge.
totalColumns integer query Number of columns to merge.
folder string query The folder that contains the workbook.
storageName string query The storage name.

The OpenAPI Specification defines a publicly accessible programming interface and lets you carry out REST interactions directly from a web browser.

You can use the cURL command line tool to access Aspose.Cells web services easily. The following example shows how to make calls to the Cloud API with cURL.

Response

HTTP Code Meaning Description
200 Success Cells merged successfully. Returns { "Code":200, "Status":"OK" }.
400 Bad Request Missing or invalid parameters. Error payload includes details.
401 Unauthorized Invalid or expired JWT token.
404 Not Found Specified workbook or worksheet does not exist.
500 Internal Server Error Server‑side problem.

FAQ

How do I merge a range of cells using Aspose.Cells Cloud API?
Use the POST endpoint https://api.aspose.cloud/v3.0/cells/{name}/worksheets/{sheetName}/cells/merge with query parameters startRow, startColumn, totalRows, and totalColumns. Include a valid JWT token in the Authorization header. A successful call returns { "Code":200, "Status":"OK" }.

What authentication is required for the merge‑cells request?
A bearer JWT token generated from your Aspose Cloud client credentials must be sent in the Authorization: Bearer <token> header. Tokens are obtained via the OAuth 2.0 token endpoint documented in the Authentication guide.

What error codes might I receive when merging cells, and how should I handle them?

  • 400 Bad Request – missing or invalid parameters.
  • 401 Unauthorized – invalid or expired JWT token.
  • 404 Not Found – workbook or worksheet does not exist.
  • 500 Internal Server Error – server‑side issue.

Handle errors by checking the Code field and inspecting the error message in the response body.

Cloud SDK Family

Using an SDK is the best way to speed up development. An SDK handles low‑level details so you can focus on your project tasks. Please check out the GitHub repository for a complete list of Aspose.Cells Cloud SDKs.

The following code examples demonstrate how to make calls to Aspose.Cells web services using various SDKs: