Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I programmatically determine Excel's list separator symbol?

Tags:

excel

Not all configurations of Excel use the same list separator symbol. In particular, it is common for Excel to use "," as the list separator in the United States and ";" as the list separator in Europe. Among other things, this affects the syntax for disjoint ranges. The same range may be formally expressed as "Sheet0!A1:B2,Sheet0!C3:D4" on one computer, but "Sheet0!A1:B2;Sheet0!C3:D4" on another computer.

I am writing code to manipulate disjoint ranges. I need to know when to use the "," syntax and when to use the ";" syntax (or, perhaps, when to use something completely different). How can I figure out what syntax to use?

Note that I'm aware that I can read the list separator from the regional settings (as described here). However, I don't want to know the regional setting per se; I want to know Excel's setting. Perhaps they are always the same, but I've seen no claim to that effect.

I'm looking for a solution for all versions of Excel, 2010 and newer. I'm using C# and Excel-DNA, but I would be grateful for a solution in any language.

like image 982
Lork Avatar asked Aug 15 '17 18:08

Lork


1 Answers

You can use the property below; which returns the type of separator as a string.

  Application.International(xlListSeparator)
like image 139
Slaqr Avatar answered Oct 05 '22 23:10

Slaqr