This project has moved and is read-only. For the latest updates, please go here.

KeyNotFoundException when trying to access worksheet from range

Sep 14, 2012 at 3:20 PM
Edited Sep 14, 2012 at 3:21 PM

Wanted to get Worksheet in which the range is located but got an error. Following code gave me this error:


var ws = Workbook.Range("someRange").Worksheet;



The given key was not present in the dictionary. "


Workbook is XLWorkbook object and someRange is a NamedRange defined in Workbook scope.

Kind Regards



Sep 14, 2012 at 3:45 PM

Create an issue and attach the file.

Sep 14, 2012 at 4:12 PM

Tried to reproduce it in clean project to upload it for you and found out that was my mistake.

I'm loading data from xml file and inserting data from tables into namedranges. Table name and range name must be the same to do the projection. Had 1 table that was used for something else and that caused the problem.


In other words I tried to access worksheet by range that doesn't exist which caused exception.


 Sorry for the trouble.

BTW. Awesome library ;)


Kind Regards