Learn how to merge cells in Excel using a C# REST API with Aspose.Cells Cloud. This step‑by‑step guide shows you how to combine rows or columns in an Excel worksheet through the C# Low Code API and the .NET‑based Cloud SDK.
Prerequisite
- Create an account and get API credentials for merging cells
- Download Aspose.Cells Cloud SDK for Dotnet to combine cells
- Set up a C# project with the above SDK
Steps to Merge Cells using C# RESTful Service
- Define the clientID, clientSecret, and apiBaseUrl required to authenticate and connect to Aspose Cloud
- Using the credentials and base URL, initialize the CellsApi object for making API calls
- Define source Excel file name and remote file names under which the file will be saved in the cloud
- Upload the file to Cloud storage using the cellsApi.UploadFile() method
- Create a PostWorksheetMergeRequest object, set the start/end cells and merge area size
- Execute the request using the PostWorksheetMerge() method
- Download the updated Excel file from the Cloud using the DownloadFileRequest
These steps describe how to combine rows in Excel using C# .NET-based API or columns of your choice. The process authenticates with Aspose.Cells Cloud, using provided credentials, uploads a local Excel file to Cloud storage and merges a 4x4 range of cells starting at cell B2 on Sheet1. It then downloads the modified file and saves it local disk.
Code to Merge Cells in Spreadsheet using C# REST Interface
The example above illustrates how to merge cells using the C# REST interface. You can loop through multiple ranges to merge them, or merge cells conditionally by examining their content or formatting. To merge cells within a single column—such as column B—just set the start column to 1, total columns to 1, and specify the required number of rows.
In this guide we walked through how to merge cells, rows, or columns using the C# REST API. When you’re ready to add an auto‑filter to your Excel workbook, check out the companion article on Apply filter in Excel using C# REST API.