Quantcast
Channel: ClosedXML - The easy way to OpenXML
Viewing all articles
Browse latest Browse all 1877

Commented Unassigned: Formula evaluation fails with single quotes in worksheet name [9402]

$
0
0
This seems rather fundamental, but after an extensive search I can't seem to find anything related to a problem I'm having.

I'm getting a "Identifier Expected" error when trying to evaluate a formula with the worksheet name in single quotes and containing spaces:
```
string test = "IF('Income & Expense'!H34 <> \"\", 'Income & Expense'!H34, IF('Income & Expense'!H35 <> \"\", 'Income & Expense'!H35, \"\"))";
var val = multiWorkbook.Evaluate(test);
```
I simplified this to:
```
string test = "'Income & Expense'!H34";
```
and get the same "Identifier Expected" error. Removing the single quotes I get "There isn't a worksheet named Expense".

Is there another way to specify spaces in worksheet names? Or is something else going on?
Comments: Check out this posting to see suggestions for worksheet names [http://www.excelcodex.com/2012/06/worksheets-naming-conventions/](http://www.excelcodex.com/2012/06/worksheets-naming-conventions/) It says that if you include a space in the worksheet name, Excel would add the single quotes to the name itself. So to access the name from code you would need to put the quotes around the whole thing, which you did. Try writing the formula in Excel and see if it works, and then try using it in the ClosedXML application.

Viewing all articles
Browse latest Browse all 1877

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>