This article explains how to avoid unexpected token exception in XlsIO using C#/VB.NET
What is unexpected token exception?
Unexpected token exception occurs when some arguments or tokens are misplaced or misused in a formula. In XlsIO, while parsing the formula, it is split into tokens. When a token is not a valid one then, the unexpected token exception will be thrown. Argument separator in a formula can be a reason for the exception.
For example, consider that we need to add two numbers using formula like following code.
If we use semicolon (;) instead of comma (,) in the formula like this:
Unexpected token exception will be thrown. This is because, comma (,) is used as a default arguments separator while formula parsing in XlsIO. So, when it encounters semicolon (;) it throws unexpected token exception.
In this case, we can avoid this exception by setting arguments separator as semicolon (;).
Note: If you face this exception in other similar cases, initially you should check whether all the tokens in the formula are used correctly. If you are not sure about the separator to be used, set separators on your own before using the formula.
The following C#/VB.NET code shows how to avoid the unexpected exception in XlsIO.
The below screenshot shows the output generated by XlsIO with formula.
|Article ID:||Published Date:||Last Revised Date:||Platform:||Control:|