This tutorial guides on how to merge cells in Excel using C# REST API. You will learn to combine cells in Excel using C# Low Code API by using a .NET-based Cloud SDK. It will assist you to merge only rows or columns as per the requirements.
Prerequisite
- Create an account and get API credentials for merging cells
- Download Aspose.Cells Cloud SDK for Dotnet to combine cells
- Setup 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
This sample code has demonstrated the process to merge cells using C# REST Interface. You can merge multiple ranges in a loop and also merge cells based on content or formatting by fetching the cell content and formatting. You can merge cells in a single column, such as column B, by setting start column 1 and total columns 1 alongside the number of rows.
This article has taught us the process of merging cells, rows, or columns. To apply auto-filter in an Excel file, refer to the article on Apply filter in Excel using C# REST API.