Excel Parsing using NuGet NPOI using ASP.Net Core 2.0

Viewed 6076

I am using visual studio 2017 most updated version and Asp.Net Core 2.0 SDK to create a Web Api that needs to read excel which was uploaded earlier into Azure File Storage. Now I am able to get the excel file downloaded but I need to read and parse individual cells from the excel sheet. To achieve this currently I am trying to use Package manager NPOI (Nuget).

Below is the command I am using for this:

Pm> Install-Package NPOI -Version 2.3.0

But after running this I get the below error:

Unable to find Package from NuGet

Note, I have checked in my "Project.csproj" file for adding appropriate refernce of , but even after adding it’s not working..

Below is my Project.csproj file:

<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>netcoreapp2.0</TargetFramework>
</PropertyGroup>

<ItemGroup>
<Folder Include="Services\" />
<Folder Include="wwwroot\" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.All" Version="2.0.0" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="1.0.0" />
<PackageReference Include="AspNetCore.NPOI" Version="2.3.0" />
</ItemGroup>

<ItemGroup>
<DotNetCliToolReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Tools" Version="2.0.0" />
</ItemGroup>

</Project>

.... Appreciate quick response!

4 Answers

NPOI 2.4 supports .NET core 2.0 now. Please update your NPOI package from nuget.

You can try adding [DOTNETCore.NPOI][Nuget Package], if you are working with .NET 2.0 Core App.

screenshot

I'll suggest you to install it through NUGET package manager. Go to VS IDE->Tools->NuGet Package Manager-> Manage NuGet Packages for Solution.

Search NPOI online and install it for your project. enter image description here

see this link too

According to your description, I check NPOI 2.3.0 with my Net Core 2.0 Web API application. I found I could install this package successfully, but I got the following warning:

enter image description here

Then I read a .xlsx file and got the following error:

enter image description here

Then I manually installed the System.Configuration.ConfigurationManager package, but got the new error as follows:

enter image description here

Per my understanding, we could manually install SharpZipLib 1.0.0-alpha2 which may compatible with NetCore 2.0, but the NPOI may not fully compatible with your NetCore application. I have tested the same method for reading .xlsx file via NPOI under my .Net Framework project and it could work as expected. I would recommend you could use ExcelDataReader 3.2.0 or EPPlus instead of NPOI.

Related