JanKallman / EPPlus

Create advanced Excel spreadsheets using .NET
3.76k stars 1.18k forks source link

UWP application IndexOutOfRange exception #586

Closed citro333 closed 4 years ago

citro333 commented 4 years ago

I'm trying to use EPPlus for UWP application but I still got IndexOutOfRange exception on Worksheet object. The same code works fine in Windows Forms project. Here is the part of the code that makes problem:

ExcelWorksheet ws = new ExcelPackage (new FileInfo(@"D:\test.xlsx")).Workbook.Worksheets[1];

afunc233 commented 4 years ago

i think you should see Example first

rubend30 commented 4 years ago

You probably should use index 0 instead of 1 to get the first worksheet (unless you want the second).

EPPlus changed in newer versions and indexes now start on 0 instead of 1. Check if your application use 0 or 1 based indexes using the following:

yourExcelPackage.Compatibility.IsWorksheets1Based

If this is not the problem, then we need more information.

citro333 commented 4 years ago

Well, I reinstalled the Visual Studio, because I noticed some problems with other UWP projects as well and now the code works fine. I'm sorry for my first post as the problem was on my side not in EPPlus library.