split excel

Split Excel (XLS, XLSX) files in C# .NET

Excel is a powerful tool for managing and analyzing data, but sometimes, dealing with large Excel files can be overwhelming. If you find yourself struggling with Excel files that are too large to manage, splitting them into smaller files can help. Fortunately, with .NET REST API, splitting an Excel files can be a straightforward and efficient process. In this tutorial, we’ll walk you through the steps of splitting Excel workbook into multiple files using C# .NET, so you can take control of your data and optimize your workflow.

Split Excel API

Aspose.Cells Cloud SDK for .NET is a powerful tool that allows developers to work with Excel files in the cloud. One of the key features of this SDK is the ability to split large Excel files into smaller ones, which can be incredibly useful for managing and analyzing data. In this section, we’ll show you how to use this SDK to split Excel files (XLS, XLSX), step by step. Whether you’re new to the SDK or just looking to learn more about splitting Excel files, our guide has got you covered. Let’s get started!

Now we need to add its reference in our application via NuGet package manager. Search “Aspose.Cells-Cloud” and click the Add Package button. Secondly, if you do not have an account over Cloud Dashboard, please create a free account by using a valid email address and obtain your personalized credentials.

How to Split Excel using C#

In this section, we are going to load two worksheets from cloud storage and then merge the second Excel workbook to the first.

Let’s understand the above code snippet:

CellsApi cellsInstance = new CellsApi(clientID, clientSecret);

Create an object of CellsApi while passing client credentials as arguments.

cellsInstance.UploadFile("myDocument.xlsx", File.OpenRead(first_Excel));

Upload input Excel to cloud storage with given name.

var response = cellsInstance.CellsWorkbookPostWorkbookSplit(first_Excel, "XLSX", from: 1, to: 2, null, null, null);

Call API to initiate Excel split operation. The worksheet split operation will start from index 1 to index 2. The resultant worksheets will be saves in the same cloud storage.

Excel split

Excel split preview.

The sample Excel workbooks used in the above example can be downloaded from myDocument.xlsx.

Split Excel Online using cURL Commands

If you prefer working with command-line tools, cURL is a powerful tool that allows you to transfer data using a variety of protocols, including HTTP, HTTPS, FTP, and more. One of the key benefits of using cURL commands for Excel splitting is that it allows you to automate the process, making it faster and more efficient. With cURL commands, you can split Excel files into smaller ones using a REST API, which can be incredibly useful for managing and analyzing data. Whether you’re new to cURL and REST APIs, our guide will walk you through the process of splitting Excel files, so you can better manage your data.

Let’s get started by generating a JWT access token based on client credentials:

curl -v "https://api.aspose.cloud/connect/token" \
-X POST \
-d "grant_type=client_credentials&client_id=bb959721-5780-4be6-be35-ff5c3a6aa4a2&client_secret=4d84d5f6584160cbd91dba1fe145db14" \
-H "Content-Type: application/x-www-form-urlencoded" \
-H "Accept: application/json"

Now that we have a JWT token, we need to use PostWorkbookSplit API to split Excel workbook. Please execute the following command.

curl -v -X POST "https://api.aspose.cloud/v3.0/cells/myDocument.xlsx/split?format=XLSX&from=2&to=3&splitNameRule=ExtractSheet" \
-H  "accept: application/json" \
-H  "authorization: Bearer <JWT Token>"

Concluding Remarks

In this tutorial, we’ve covered two approaches for splitting Excel files: using C# .NET and using a REST API with cURL commands. Both methods have their own benefits, and the choice ultimately depends on your specific needs and preferences. With C# .NET, you have a powerful tool at your disposal for splitting Excel files on your desktop or mobile. On the other hand, using a REST API with cURL commands allows you to automate the process and split Excel files in the cloud. Whichever method you choose, our step-by-step guide has provided you with the knowledge and skills to split Excel files like a professional. Start optimizing your Excel workflow today!

Please visit the following links to learn more about: