ExceldataReader.DataSet Extension

117 views Asked by At

I have installed the nuget package exceldatareader and the extension exceldatareader.dataset but when trying to reference it in the using statement it does not recognize it

'''
using Microsoft.AspNetCore.Mvc;
using FleetManagerComLog.Models;
using ExcelDataReader;
using ExcelDataReader.DataSet;
'''

Error

I have confirmed via the NugetPackage manager that it is installed.

When trying to add it via the using I do get the following options .Core, .Exceptions & .Log but not .DataSet.

/Edit

Error using .AsDataSet() after using ExcelDataReader has been added

/Edit 2

Image of the Solution Explorer

/Edit 3

Image of csproj file

/Thomas

1

There are 1 answers

6
Panagiotis Kanavos On BEST ANSWER

AsDataSet() is defined in the ExcelDataReader namespace, in the ExcelDataReader.DataSet package. There's no separate ExcelDataReader.DataSet namespace. You only need using ExcelDataReader to use AsDataSet() :

using ExcelDataReader;

...
using var stream = File.Open(filePath, FileMode.Open, FileAccess.Read));
using var reader = ExcelReaderFactory.CreateReader(stream);

var result = reader.AsDataSet();

You do have to add the ExcelDataReader.DataSet package though