Пример #1
0
        public ExcelCell this[string contextName]
        {
            get
            {
                int firstRow;
                int firstColumn;
                switch (this.IndexingMode)
                {
                case RangeIndexingMode.Rectangular:
                    PositionToRowColumn(contextName, out firstRow, out firstColumn);
                    break;

                case RangeIndexingMode.Horizontal:
                    firstRow    = this.firstRow;
                    firstColumn = ExcelColumnCollection.ColumnNameToIndex(contextName);
                    break;

                case RangeIndexingMode.Vertical:
                    firstRow    = ExcelRowCollection.RowNameToIndex(contextName);
                    firstColumn = this.firstColumn;
                    break;

                default:
                    throw new Exception("Internal: Unknown indexing mode.");
                }
                this.ExceptionIfRowColumnOutOfRange(firstRow, firstColumn);
                return(base.Parent.Rows[firstRow].AllocatedCells[firstColumn]);
            }
        }
Пример #2
0
        public static void SetAreaRows(string value, out ushort firstRow, out ushort lastRow)
        {
            firstRow = 0;
            lastRow  = 0;
            Match match = IsCellRangeRegex.Match(value);

            firstRow = (ushort)ExcelRowCollection.RowNameToIndex(match.Groups["Row1"].Value);
            lastRow  = (ushort)ExcelRowCollection.RowNameToIndex(match.Groups["Row2"].Value);
        }
Пример #3
0
 private void SetLastRow(string row)
 {
     if (row[0] == RefFormulaToken.AbsoluteCellMark)
     {
         this.IsLastRowRelative = false;
         row = row.Substring(1);
     }
     else
     {
         this.IsLastRowRelative = true;
     }
     this.lastRow = (ushort)ExcelRowCollection.RowNameToIndex(row);
 }
Пример #4
0
 private void SetRow(string row)
 {
     if (row[(0)] == AbsoluteCellMark)
     {
         this.IsRowRelative = false;
         row = row.Substring(1);
     }
     else
     {
         this.IsRowRelative = true;
     }
     this.row = (ushort)ExcelRowCollection.RowNameToIndex(row);
 }
Пример #5
0
        internal static void PositionToRowColumn(string position, out int row, out int column, out bool wrongFormat)
        {
            string name = position.Split(new char[] { '1', '2', '3', '4', '5', '6', '7', '8', '9' }, 2)[0];

            if ((name.Length != 0) && (name.Length != position.Length))
            {
                string str2 = position.Remove(0, name.Length);
                row         = ExcelRowCollection.RowNameToIndex(str2);
                column      = ExcelColumnCollection.ColumnNameToIndex(name);
                wrongFormat = false;
            }
            else
            {
                column      = -1;
                row         = -1;
                wrongFormat = true;
            }
        }
Пример #6
0
        private static bool IsValidCell(Match regexMatch)
        {
            string name = regexMatch.Groups["Row"].Value;

            if (name[0] == AbsoluteCellMark)
            {
                name = name.Remove(0, 1);
            }
            string str2 = regexMatch.Groups["Column"].Value;

            if (str2[0] == AbsoluteCellMark)
            {
                str2 = str2.Remove(0, 1);
            }
            return(IsColumnValid(ExcelColumnCollection.ColumnNameToIndex(str2)) && IsRowValid(ExcelRowCollection.RowNameToIndex(name)));
        }
Пример #7
0
 public static ushort CellToRow(string value)
 {
     return((ushort)ExcelRowCollection.RowNameToIndex(IsCellRegex.Match(value).Groups["Row"].Value));
 }