EPPlus - ExcelWorksheet object getting null when assigning to another object

Viewed 133

I updated EPPlus version 3.1.3.0 to 4.1.1 in my C# Winform application and getting subject issue. Same code working fine in previous version.

Below is my code which reads Excel file and get sheet by Name with below code.

enter image description here

Above code works fine and sheet data comes in "item" object like following:

enter image description here

But once I assign "item" ExcelWorksheet object to another ExcelWorksheet object to return it to calling method so its internal members getting null.

like following:

enter image description here

1 Answers

I just fixed the issue.

Following line was creating issue in new version of EPPlus:

using (var package = new ExcelPackage(existingFile))

In new version of EPPlus, package object must not be disposed in order to read Worksheet. So I removed using and it works fine now.

Related