DEV Community

Shahzad Ashraf
Shahzad Ashraf

Posted on

Read and Extract Text from XLSX in C# with .NET REST API

Extracting text from Excel spreadsheets is a crucial aspect of document processing applications within the .NET framework. The text content obtained can serve multiple purposes such as data analysis, storage, classification, and beyond. Developers can programmatically retrieve text from XLSX files with just a few lines of code, without the need for Microsoft Excel or bulky file processing libraries, thanks to the GroupDocs.Parser Cloud .NET SDK. This SDK is tailored for cloud-centric applications, facilitating effortless integration with REST APIs and document automation processes.

Whether you are creating an audit tool or simply wish to extract the information from XLSX files in C#, this .NET Cloud SDK for Excel parsing streamlines the process significantly. You can obtain both structured and unstructured text from individual cells and entire workbooks within Excel spreadsheets. It is scalable, secure, and optimized for cloud-driven .NET solutions.

Discover how to extract text from XLSX files in .NET with minimal effort and maximum control by leveraging the features of the GroupDocs.Parser Cloud .NET REST API. It assists you in refining your document processing workflows, eliminating unnecessary dependencies, and enhancing the efficiency of your application stack. Visit our comprehensive guide for a complete tutorial and code examples to assist you in getting started with this functionality in your .NET applications.

The following C# code example can help you incorporate this functionality into your .NET projects seamlessly:

using GroupDocs.Parser.Cloud.Sdk.Api;
using GroupDocs.Parser.Cloud.Sdk.Client;
using GroupDocs.Parser.Cloud.Sdk.Model;
using GroupDocs.Parser.Cloud.Sdk.Model.Requests;

class Program
{
    static void Main(string[] args)
    {

        // Step 1: Set up API credentials and initialize configuration
        string MyAppKey = "your-app-key";
        string MyAppSid = "your-app-secret";
        var configuration = new Configuration(MyAppKey, MyAppSid);

        // Step 2: Initialize Parse API for extracting XLSX text
        var parseApi = new ParseApi(configuration);

        // Step 3: Set up the file info with FileInfo
        var fileInfo = new GroupDocs.Parser.Cloud.Sdk.Model.FileInfo
        {
            // Path of the file in cloud storage
            FilePath = "SampleFiles/source.xlsx"
        };

        // Step 4: Set text options 
        var options = new TextOptions
        {
            FileInfo = fileInfo,
        };

        // Step 5: Create and execute the text extraction request
        var textRequest = new TextRequest(options);
        var textResponse = parseApi.Text(textRequest);
    }
}
Enter fullscreen mode Exit fullscreen mode

Top comments (0)