ToAddress() 공개 메소드

public ToAddress ( int col, int row ) : string
col int
row int
리턴 string
예제 #1
0
 public override CompileResult Execute(IEnumerable<FunctionArgument> arguments, ParsingContext context)
 {
     ValidateArguments(arguments, 2);
     var row = ArgToInt(arguments, 0) - 1;
     var col = ArgToInt(arguments, 1) - 1;
     ThrowExcelFunctionExceptionIf(() => row < 0 && col < 0, ExcelErrorCodes.Value);
     var referenceType = ExcelReferenceType.AbsoluteRowAndColumn;
     var worksheetSpec = string.Empty;
     if (arguments.Count() > 2)
     {
         var arg3 = ArgToInt(arguments, 2);
         ThrowExcelFunctionExceptionIf(() => arg3 < 1 || arg3 > 4, ExcelErrorCodes.Value);
         referenceType = (ExcelReferenceType)ArgToInt(arguments, 2);
     }
     if (arguments.Count() > 3)
     {
         var fourthArg = arguments.ElementAt(3).Value;
         if(fourthArg.GetType().Equals(typeof(bool)) && !(bool)fourthArg)
         {
             throw new InvalidOperationException("Excelformulaparser does not support the R1C1 format!");
         }
         if (fourthArg.GetType().Equals(typeof(string)))
         {
             worksheetSpec = fourthArg.ToString() + "!";
         }
     }
     var translator = new IndexToAddressTranslator(context.ExcelDataProvider, referenceType);
     return CreateResult(worksheetSpec + translator.ToAddress(col, row), DataType.ExcelAddress);
 }
예제 #2
0
 public RangeAddress Create(int col, int row)
 {
     return(new RangeAddress()
     {
         Address = _indexToAddressTranslator.ToAddress(col, row),
         Worksheet = string.Empty,
         FromCol = col,
         ToCol = col,
         FromRow = row,
         ToRow = row
     });
 }