Search code examples
c#asp.netexceldatareader

ExceldataReader.DataSet Extension


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


Solution

  • 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