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

Error in tokenizer?

Jan 21, 2015 at 12:48 PM
I tried to use the (undocumented) formula parsing thing, I would like to know which worksheet a cell is linked to:
var Formula = c.Formula;
var tokens = formulaParser.Lexer.Tokenize(Formula);
var references = tokens.Where(x => x.TokenType == TokenType.ExcelAddress);
For a worksheet with the following name: "A - B", I get a formula:
'A - B'!A1
This is parsed as three tokens:
  • 'A
  • -
  • B'!A1
Meaning only the last of them is considered being a reference.
Jan 21, 2015 at 4:15 PM
Hej Niklas,

I have just (in another issue) discovered a bug in EPPlus that causes this error when the worksheet name contains a "-". We will fix this in next version, but in the meantime you need to rename the worksheet, removing the "-".

/Mats
Jan 28, 2015 at 1:57 PM
Edited Jan 28, 2015 at 1:58 PM
Hej,

I solved it by backtracking through the tokens and stopping at anything that begins with '.
A variation of the same problem, or possibly another and related;

'A - B. C'!A10

Seems to be interpreted as
  • A
  • -
  • B. C'A10
The difference here is that the last one is of type named range instead.