ColRowToReference() static private method

Convert a zero-based row and column to an Excel Cell Reference, e.g. A1 for [0,0]
static private ColRowToReference ( int col, int row ) : string
col int
row int
return string
Beispiel #1
0
        /// <summary>
        /// Freezes rows at the top and columns on the left.
        /// </summary>
        /// <param name="rows">The number of rows to freeze.</param>
        /// <param name="columns">The number of columns to freeze.</param>
        /// <param name="activePane">The pane that's selected in the sheet. Leave null to automatically determine this.</param>
        public void FreezeTopLeft(int rows, int columns, Panes?activePane = null)
        {
            // TODO: Eventually, support more SheetView functionality, right now, keep it simple.
            if (_sheetViews != null)
            {
                throw new InvalidOperationException("You have already frozen rows and/or columns on this Worksheet.");
            }

            if (rows < 0)
            {
                throw new ArgumentOutOfRangeException(nameof(rows), "Rows cannot be negative.");
            }

            if (columns < 0)
            {
                throw new ArgumentOutOfRangeException(nameof(columns), "Columns cannot be negative.");
            }

            if (columns == 0 && rows == 0)
            {
                return;
            }

            if (!activePane.HasValue)
            {
                if (columns == 0)
                {
                    activePane = Panes.BottomLeft;
                }
                else if (rows == 0)
                {
                    activePane = Panes.TopRight;
                }
                else
                {
                    activePane = Panes.BottomRight;
                }
            }

            var sheetView = new SheetView
            {
                Pane = new Pane
                {
                    ActivePane  = activePane.Value,
                    XSplit      = columns > 0 ? (int?)columns : null,
                    YSplit      = rows > 0 ? (int?)rows : null,
                    TopLeftCell = CellAddressHelper.ColRowToReference(columns, rows),
                    State       = PaneState.Frozen
                }
            };

            sheetView.AddSelection(new Selection {
                ActivePane = activePane.Value
            });
            AddSheetView(sheetView);
        }
Beispiel #2
0
 /// <summary>
 /// Convert this CellAddress into a Cell Reference, e.g. A1 for [0,0]
 /// </summary>
 /// <returns></returns>
 public override string ToString()
 {
     return(CellAddressHelper.ColRowToReference(Column, Row));
 }