How to get columns from a Excel XLSX spreadsheet in C# .NET Framework
1 min readFeb 22, 2020
This lesson will show you how to extract column information from an Excel file. This is going to be a piece of cake.
First things first, head into the Package Manager console and paste in this command, so that NuGet can begin installing our API client.
Install-Package Cloudmersive.APIClient.NET.DocumentAndDataConvert -Version 2.2.0
Alright, now we can call EditDocumentXlsxGetColumns and put our API to work:
using System;using System.Diagnostics;using Cloudmersive.APIClient.NET.DocumentAndDataConvert.Api;using Cloudmersive.APIClient.NET.DocumentAndDataConvert.Client;using Cloudmersive.APIClient.NET.DocumentAndDataConvert.Model;namespace Example{public class EditDocumentXlsxGetColumnsExample{public void main(){// Configure API key authorization: ApikeyConfiguration.Default.AddApiKey("Apikey", "YOUR_API_KEY");// Uncomment below to setup prefix (e.g. Bearer) for API key, if needed// Configuration.Default.AddApiKeyPrefix("Apikey", "Bearer");var apiInstance = new EditDocumentApi();var input = new GetXlsxColumnsRequest(); // GetXlsxColumnsRequest | Document input requesttry{// Get columns from a Excel XLSX spreadsheet, worksheetGetXlsxColumnsResponse result = apiInstance.EditDocumentXlsxGetColumns(input);Debug.WriteLine(result);}catch (Exception e){Debug.Print("Exception when calling EditDocumentApi.EditDocumentXlsxGetColumns: " + e.Message );}}}}
That wasn’t so bad, right? Here’s a look at how your answer will be formatted.
{
"Successful": true,
"Columns": [
{
"Path": "string",
"HeadingCell": {
"Path": "string",
"TextValue": "string",
"CellIdentifier": "string",
"StyleIndex": 0,
"Formula": "string"
}
}
]
}