Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

EPPlus Invalid Address Format Error

Tags:

.net

excel

epplus

When trying to read an excel worksheet I receive the error Invalid Address format TABLE_QUERY_FROM_MS_ACCESS_DATABASE[BACKORDERS] It happens on this line...

 If package.Workbook.Worksheets.Count = 0 Then

Matter of fact, anytime I access the .Workbook I receive this error which is a complete show stopper for me right now. Now I've read the excel file (and I'm not an excel expert) but when I click on the Formulas tab, then I click on the Name Manager button, a dialog comes up with five columns. "Name, Value, Refers To, Scope, Comment" BackOrders has multiple entries and on all of the records under Refers To is the value =Table_Query_from_MS_Access_Database[BackOrders]

When I click on the referring location I am brought to another Worksheet in the same Workbook and the column BackOrders is highlighted. Does anyone have any idea whatsoever how I can correct this?

like image 829
Shane LeBlanc Avatar asked Feb 06 '26 05:02

Shane LeBlanc


1 Answers

Your column name as a space in it. The bug is here: https://epplus.codeplex.com/workitem/14779

A fast work around that worked for me was to just do the failing call twice like so:

var ws;
try{
    ws = package.Workbook.Worksheets[1];
}catch( Exception ){
    ws = package.Workbook.Worksheets[1];
}

In my simple case it sufficed to keep me going.

like image 64
LosManos Avatar answered Feb 09 '26 07:02

LosManos



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!