In a VSTO project for Excel written in C#, I need to get the Range object from a string list of cells.
Here is a simplified version of the problem:
string strRange = "A1:A2,A5";
Excel.Range r = sheet.get_Range(strRange);
However since the list separator can be different from the comma in different culture settings I'm actually using this:
listSep = System.Globalization.CultureInfo.CurrentCulture.TextInfo.ListSeparator;
string strRange = "A1:A2" + listSep + "A5";
Excel.Range r = sheet.get_Range(strRange);
My problem is when the user changes "Decimal Separator" in Excel Options > Advanced (the Application.DecimalSeparator) to match the ListSeparator, this won't work.
What is the correct way to call get_Range with a string specifying the Range?
EDIT: Slight modification to add information of my comment below.
Cell1:Cell2,Cell3
afaik - that's how the API works and should not be affected byListSeparator
. There is an alternative suggestion in this answer, however: #6155682 – Jany