ReaderExcel 1.1.0
dotnet add package ReaderExcel --version 1.1.0
NuGet\Install-Package ReaderExcel -Version 1.1.0
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="ReaderExcel" Version="1.1.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="ReaderExcel" Version="1.1.0" />
<PackageReference Include="ReaderExcel" />
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add ReaderExcel --version 1.1.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: ReaderExcel, 1.1.0"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package ReaderExcel@1.1.0
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=ReaderExcel&version=1.1.0
#tool nuget:?package=ReaderExcel&version=1.1.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
ReaderExcel Utility
ReaderExcel is a simple utility library designed to read Excel files and parse their content into structured data, making it easy to work with tabular data programmatically.
Features
- Reads
.xlsxfiles using ClosedXML. - Parses rows and columns into a list of key-value pairs.
- Skips header rows for clean data extraction.
- Returns HTTP status codes for easy error handling.
Installation
To install the package via NuGet, run the following command in the Package Manager Console:
Install-Package ReaderExcel
Usage
Here is an example of how to use the ReaderExcel method to read an Excel file:
using System;
using System.Collections.Generic;
using System.Net;
class Program
{
static void Main(string[] args)
{
string filePath = @"path/to/your/excel/file.xlsx";
var result = ReadingFile(filePath);
if (result.response == HttpStatusCode.OK)
{
Console.WriteLine("File read successfully!");
foreach (var row in result.table)
{
foreach (var pair in row)
{
Console.WriteLine($"{pair.Key}: {pair.Value}");
}
Console.WriteLine();
}
}
else
{
Console.WriteLine("Failed to read file.");
}
}
public static (List<List<KeyValuePair<string, string>>>? table, HttpStatusCode response) ReadingFile(string filePath)
{
try
{
using (var workbook = new XLWorkbook(filePath))
{
var worksheet = workbook.Worksheet(1);
var range = worksheet.RangeUsed();
int rows = range.RowCount();
int cols = range.ColumnCount();
List<List<KeyValuePair<string, string>>> table = new();
for (int row = 2; row <= rows; row++)
{
var values = new List<KeyValuePair<string, string>>();
for (int col = 1; col <= cols; col++)
{
var column = range.Cell(1, col).Value.ToString();
var rowValue = range.Cell(row, col).Value.ToString();
KeyValuePair<string, string> valuePair = new(column, rowValue);
values.Add(valuePair);
}
table.Add(values);
}
return (table, HttpStatusCode.OK);
}
}
catch (Exception e)
{
return (null, HttpStatusCode.BadRequest);
}
}
}
Returns
The ReaderExcel method returns a tuple with the following elements:
- table: A list of lists of key-value pairs, where each row represents a record, and each key-value pair represents a column name and its value.
- response: An
HttpStatusCodeindicating the status of the operation (e.g.,OKfor success,BadRequestfor errors).
Requirements
- .NET 6.0 or higher.
- ClosedXML library.
Author
Licence
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
net8.0
- ClosedXML (>= 0.104.2)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.