/// <summary>
 /// Translates an address in format "A1" to col- and rowindex.
 /// </summary>
 /// <param name="address"></param>
 /// <param name="col"></param>
 /// <param name="row"></param>
 /// <param name="behaviour"></param>
 public virtual void ToColAndRow(string address, out int col, out int row, RangeCalculationBehaviour behaviour)
 {
     address = address.ToUpper();
     var alphaPart = GetAlphaPart(address);
     col = 0;
     var nLettersInAlphabet = 26;
     for (int x = 0; x < alphaPart.Length; x++)
     {
         var pos = alphaPart.Length - x - 1;
         var currentNumericValue = GetNumericAlphaValue(alphaPart[x]);
         col += (nLettersInAlphabet * pos * currentNumericValue);
         if (pos == 0)
         {
             col += currentNumericValue;
         }
     }
     col--;
     row = GetIntPart(address) - 1 ?? GetRowIndexByBehaviour(behaviour);
 }
Example #2
0
 private int GetRowIndexByBehaviour(RangeCalculationBehaviour behaviour)
 {
     if (behaviour == RangeCalculationBehaviour.FirstPart)
     {
         return 1;
     }
     return _excelDataProvider.ExcelMaxRows;
 }