AUTHOR: Peter Milchev
DATE POSTED: April 17, 2018
Expected op «,» but found punc «;» error is thrown in the console when loading an Excel file in Spreadsheet.
Expected op «,» but found punc «;»
By default, the Spreadsheet uses the separators for the English culture while Excel depends on the current culture in order to determine which separators to use.
That can cause issues when the current culture's separators are different from the English culture's ones. For example, the list separator for the English culture is a comma "," while in some cultures it is a semicolon ";".
The AVERAGE formula for the English culture looks like =AVERAGE(1,3,5,6). In cultures where the list separator is a semicolon, the same formula will be rendered as =AVERAGE(1;3;5;6). When the Spreadsheet tries to parse the latter formula, it will throw the Expected op «,» but found punc «;» error.
One option to resolve this issue is to load the Excel file with the following approach
sender, EventArgs e)
Session[sessionKeyProviderSpreadsheet] = provider;
provider = (MySpreadsheetProvider)Session[sessionKeyProviderSpreadsheet];
// save the current culture
var currentCulture = Thread.CurrentThread.CurrentCulture;
var currentUICulture = Thread.CurrentThread.CurrentUICulture;
// set the current culture to English
Thread.CurrentThread.CurrentCulture = CultureInfo.CreateSpecificCulture(
// load the file
MySheet.Provider = provider;
// restore the current culture
Thread.CurrentThread.CurrentCulture = currentCulture;
Thread.CurrentThread.CurrentUICulture = currentUICulture;