This tutorial guides on how to search text in Excel using C# REST API. You will learn to automatically search text in Excel files using C# RESTful Service using a .NET-based Cloud SDK. It will explain the details of searching text in a single or a collection of Excel files and display the searched text in each file.
Prerequisite
- Create an account and get API credentials for searching text
- Download Aspose.Cells Cloud SDK for Dotnet to find text in a single or multiple Excel files
- Setup C# project with the above SDK
Steps to Find Text in Excel using C# REST Interface
- Define the App Client ID, Secret, and Aspose Cloud API URL
- Create an instance of CellsApi using the provided credentials
- Create a dictionary to map Excel file names to their file streams
- Search all .xlsx files in the current directory and its subfolders
- Loop through each Excel file and add its stream to the dictionary
- Build a PostSearchRequest with the uploaded files and search text
- Call PostSearch to search for the text across all uploaded Excel files
- Print the file and sheet names along with matching text to the console
These steps summarize the process to search and extract text in Excel using C# .NET-based API. The program authenticates with Aspose.Cells Cloud API, collects all .xlsx files from the current directory and subfolders and prepares them for processing. It then searches for a specific text (“table”) across these files and displays the matching sheet and file names.
Code to Search Excel for Text using C# Low Code API
The above code demonstrates how to search text in multiple Excel files using C# REST API. You may modify the code to search text in a single Excel file by adding only one Excel file to the dictionary. The search is not limited to XLSX files only; you can also add other formats like XLS to the dictionary.
This article has taught us the process of finding and displaying text from Excel file(s). To split Excel files into multiple files, refer to the article Split Excel file using C# REST API.