Esempio n. 1
0
        /// <summary>
        /// The direct contructor should only be used in <see cref="XLWorksheet.RangeFactory"/>.
        /// </summary>
        public XLColumn(XLWorksheet worksheet, Int32 column)
            : base(XLRangeAddress.EntireColumn(worksheet, column), worksheet.StyleValue)
        {
            SetColumnNumber(column);

            Width = worksheet.ColumnWidth;
        }
Esempio n. 2
0
        public override XLRange Range(string rangeAddressStr)
        {
            string rangeAddressToUse;

            if (rangeAddressStr.Contains(':') || rangeAddressStr.Contains('-'))
            {
                if (rangeAddressStr.Contains('-'))
                {
                    rangeAddressStr = rangeAddressStr.Replace('-', ':');
                }

                var    arrRange   = rangeAddressStr.Split(':');
                string firstPart  = arrRange[0];
                string secondPart = arrRange[1];
                rangeAddressToUse = FixRowAddress(firstPart) + ":" + FixRowAddress(secondPart);
            }
            else
            {
                rangeAddressToUse = FixRowAddress(rangeAddressStr);
            }

            var rangeAddress = new XLRangeAddress(Worksheet, rangeAddressToUse);

            return(Range(rangeAddress));
        }
        /// <summary>
        /// The direct contructor should only be used in <see cref="XLWorksheet.RangeFactory"/>.
        /// </summary>
        public XLRow(XLWorksheet worksheet, Int32 row)
            : base(XLRangeAddress.EntireRow(worksheet, row), worksheet.StyleValue)
        {
            SetRowNumber(row);

            _height = worksheet.RowHeight;
        }
Esempio n. 4
0
 public void ExpandTableRows(Int32 rows)
 {
     RangeAddress = new XLRangeAddress(
         RangeAddress.FirstAddress,
         new XLAddress(Worksheet, RangeAddress.LastAddress.RowNumber + rows,
                       RangeAddress.LastAddress.ColumnNumber,
                       RangeAddress.LastAddress.FixedRow,
                       RangeAddress.LastAddress.FixedColumn));
 }
 internal void SetRowNumber(Int32 row)
 {
     RangeAddress = new XLRangeAddress(
         new XLAddress(Worksheet, row, 1, RangeAddress.FirstAddress.FixedRow,
                       RangeAddress.FirstAddress.FixedColumn),
         new XLAddress(Worksheet,
                       row,
                       XLHelper.MaxColumnNumber,
                       RangeAddress.LastAddress.FixedRow,
                       RangeAddress.LastAddress.FixedColumn));
 }
Esempio n. 6
0
        public void Transpose(XLTransposeOptions transposeOption)
        {
            int rowCount    = RowCount();
            int columnCount = ColumnCount();
            int squareSide  = rowCount > columnCount ? rowCount : columnCount;

            var firstCell = FirstCell();

            MoveOrClearForTranspose(transposeOption, rowCount, columnCount);
            TransposeMerged(squareSide);
            TransposeRange(squareSide);
            RangeAddress = new XLRangeAddress(
                RangeAddress.FirstAddress,
                new XLAddress(Worksheet,
                              firstCell.Address.RowNumber + columnCount - 1,
                              firstCell.Address.ColumnNumber + rowCount - 1,
                              RangeAddress.LastAddress.FixedRow,
                              RangeAddress.LastAddress.FixedColumn));

            if (rowCount > columnCount)
            {
                var rng = Worksheet.Range(
                    RangeAddress.LastAddress.RowNumber + 1,
                    RangeAddress.FirstAddress.ColumnNumber,
                    RangeAddress.LastAddress.RowNumber + (rowCount - columnCount),
                    RangeAddress.LastAddress.ColumnNumber);
                rng.Delete(XLShiftDeletedCells.ShiftCellsUp);
            }
            else if (columnCount > rowCount)
            {
                var rng = Worksheet.Range(
                    RangeAddress.FirstAddress.RowNumber,
                    RangeAddress.LastAddress.ColumnNumber + 1,
                    RangeAddress.LastAddress.RowNumber,
                    RangeAddress.LastAddress.ColumnNumber + (columnCount - rowCount));
                rng.Delete(XLShiftDeletedCells.ShiftCellsLeft);
            }

            foreach (IXLCell c in Range(1, 1, columnCount, rowCount).Cells())
            {
                var border = (c.Style as XLStyle).Value.Border;
                c.Style.Border.TopBorder         = border.LeftBorder;
                c.Style.Border.TopBorderColor    = border.LeftBorderColor;
                c.Style.Border.LeftBorder        = border.TopBorder;
                c.Style.Border.LeftBorderColor   = border.TopBorderColor;
                c.Style.Border.RightBorder       = border.BottomBorder;
                c.Style.Border.RightBorderColor  = border.BottomBorderColor;
                c.Style.Border.BottomBorder      = border.RightBorder;
                c.Style.Border.BottomBorderColor = border.RightBorderColor;
            }
        }
Esempio n. 7
0
 internal void SetColumnNumber(int column)
 {
     RangeAddress = new XLRangeAddress(
         new XLAddress(Worksheet,
                       1,
                       column,
                       RangeAddress.FirstAddress.FixedRow,
                       RangeAddress.FirstAddress.FixedColumn),
         new XLAddress(Worksheet,
                       XLHelper.MaxRowNumber,
                       column,
                       RangeAddress.LastAddress.FixedRow,
                       RangeAddress.LastAddress.FixedColumn));
 }
        public void Add(XLRangeAddress rangeAddress)
        {
            _rangeAddresses.Add(rangeAddress);

            if (_styleInitialized)
            {
                return;
            }

            var worksheetStyle = rangeAddress.Worksheet?.Style;

            if (worksheetStyle == null)
            {
                return;
            }

            InnerStyle        = worksheetStyle;
            _styleInitialized = true;
        }
Esempio n. 9
0
        private IEnumerable <XLCell> GetUsedCellsInRange(XLRangeAddress rangeAddress, XLWorksheet worksheet, IEnumerable <XLSheetPoint> usedCellsCandidates)
        {
            if (!rangeAddress.IsValid)
            {
                yield break;
            }
            var normalizedAddress = rangeAddress.Normalize();
            var minRow            = normalizedAddress.FirstAddress.RowNumber;
            var maxRow            = normalizedAddress.LastAddress.RowNumber;
            var minColumn         = normalizedAddress.FirstAddress.ColumnNumber;
            var maxColumn         = normalizedAddress.LastAddress.ColumnNumber;

            var cellRange = worksheet.Internals.CellsCollection
                            .GetCells(minRow, minColumn, maxRow, maxColumn, _predicate)
                            .Where(c => !c.IsEmpty(_options));

            foreach (var cell in cellRange)
            {
                if (_predicate(cell))
                {
                    yield return(cell);
                }
            }

            foreach (var sheetPoint in usedCellsCandidates)
            {
                if (sheetPoint.Row.Between(minRow, maxRow) &&
                    sheetPoint.Column.Between(minColumn, maxColumn))
                {
                    var cell = worksheet.Cell(sheetPoint.Row, sheetPoint.Column);

                    if (_predicate(cell))
                    {
                        yield return(cell);
                    }
                }
            }
        }
Esempio n. 10
0
        public override XLRange Range(String rangeAddressStr)
        {
            String rangeAddressToUse;
            if (rangeAddressStr.Contains(':') || rangeAddressStr.Contains('-'))
            {
                if (rangeAddressStr.Contains('-'))
                    rangeAddressStr = rangeAddressStr.Replace('-', ':');

                var arrRange = rangeAddressStr.Split(':');
                string firstPart = arrRange[0];
                string secondPart = arrRange[1];
                rangeAddressToUse = FixRowAddress(firstPart) + ":" + FixRowAddress(secondPart);
            }
            else
                rangeAddressToUse = FixRowAddress(rangeAddressStr);

            var rangeAddress = new XLRangeAddress(Worksheet, rangeAddressToUse);
            return Range(rangeAddress);
        }
Esempio n. 11
0
        public XLRangeRow CreateRangeRow(XLRangeAddress rangeAddress)
        {
            var xlRangeParameters = new XLRangeParameters(rangeAddress, Worksheet.Style);

            return(new XLRangeRow(xlRangeParameters));
        }
Esempio n. 12
0
 public void Add(XLRangeAddress rangeAddress)
 {
     _rangeAddresses.Add(rangeAddress);
 }
Esempio n. 13
0
 public XLTable CreateTable(XLRangeAddress rangeAddress)
 {
     return(new XLTable(new XLRangeParameters(rangeAddress, Worksheet.Style)));
 }
Esempio n. 14
0
 public XLRangeKey(XLRangeType rangeType, XLRangeAddress address)
 {
     RangeType    = rangeType;
     RangeAddress = address;
 }
Esempio n. 15
0
 public XLRangeAddress(XLRangeAddress rangeAddress) : this(rangeAddress.FirstAddress, rangeAddress.LastAddress)
 {
 }
 public XLRangeAddress(XLRangeAddress rangeAddress): this(rangeAddress.FirstAddress, rangeAddress.LastAddress)
 {
     
 }
Esempio n. 17
0
 protected override void OnRangeAddressChanged(XLRangeAddress oldAddress, XLRangeAddress newAddress)
 {
     //Do nothing for table
 }