We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
close icon

Convert GridRangeInfo to Excel String Range

Hi,  I am working with GridRangeInfo to create ranges and also working with NamedRanges and need a way to convert from GridRangeInfo into "A1:B1" format.


                 var engine = ((GridFormulaCellModel) gridControl1.Model.CellModels["FormulaCell"]).Engine;
                 engine.AddNamedRange("Test", GridRangeInfo.Cells(1,1,2,2).Info);
                 var name = engine.NamedRangeValues.Values.OfType<String>().Single(s => s == "A1:B2");

Basically I want to convert between "A1:B2" format and GridRangeInfo.


5 Replies

AR Arulpriya Ramalingam Syncfusion Team June 1, 2017 10:03 AM UTC

Hi Chris, 

Thanks for your interest in Syncfusion products. 

We could able to understand your scenario. As per our current support of GridControl, the NamedRanges can be passed only as AlphaLabel ranges. So GridControl does not have direct support to convert the GridRangeInfo(i.e R1C2) to named ranges (i.e., A1).  Please refer the NamedRanges UG link to know more about NamedRanges. The reported scenario can be achieved by using GetAlphaLabel() method. GetAlphaLabel() can be used to get the AlphaLabel of the column. Please make use of below code and sample, 

Code snippet 
var engine = ((GridFormulaCellModel)gridControl1.Model.CellModels["FormulaCell"]).Engine; 
//To Pass the GridRange 
GridRangeInfo range = GridRangeInfo.Cells(1, 1, 2, 2); 
int topIndex = range.Top; 
int rightIndex = range.Right; 
//To get the alpha label for the cells 
string startAlpha = GridRangeInfo.GetAlphaLabel(range.Left); 
string endAlpha = GridRangeInfo.GetAlphaLabel(range.Right); 
//To convert the GridRange into AlphaLabelRange 
var namedRange = startAlpha + topIndex + ":" + endAlpha + rightIndex; 
//To add the namedrange 
engine.AddNamedRange("Test", namedRange); 


CB Chris Bishop June 1, 2017 01:27 PM UTC

That is not acceptable.Your offer a GridControl that supports excel ranges in string format but use your own object for handling ranges in code and then do not provide a way to switch between them.  This is ludicrous that you expect the developer to create their own conversion method.  I need to switch between the two.If you don't have this feature it needs to be added.

AR Arulpriya Ramalingam Syncfusion Team June 2, 2017 08:33 AM UTC

Hi Chris, 
Thanks for your update. 
We have created the separate incident for the reported scenario for better follow-up under your account. Please follow-up with that incident. 

CB Chris Bishop June 2, 2017 01:40 PM UTC

Thank you,

I appreciate that.

AR Arulpriya Ramalingam Syncfusion Team June 5, 2017 09:51 AM UTC

Hi Chris,  

Thanks for your appriciation. 


Live Chat Icon For mobile
Up arrow icon