Пример #1
0
        private static void ResolveBorder(CellStyle bordersStyle, MergedCellRange mergedRange, IndividualBorder borderId, int row, int column, int rowInc, int colInc)
        {
            CellBorder border = bordersStyle.Borders[borderId];
            bool       flag   = true;

            while (row < mergedRange.Height)
            {
                if (column >= mergedRange.Width)
                {
                    return;
                }
                CellBorder border2 = mergedRange[row, column].Style.Borders[borderId];
                if (flag)
                {
                    border.LineStyle = border2.LineStyle;
                    border.LineColor = border2.LineColor;
                    flag             = false;
                }
                else if ((border2.LineStyle != border.LineStyle) || (border2.LineColor != border.LineColor))
                {
                    border.LineStyle = LineStyle.None;
                    border.LineColor = Color.Empty;
                    return;
                }
                row    += rowInc;
                column += colInc;
            }
        }
Пример #2
0
        internal void Add(MergedCellRange mergedRange)
        {
            if (mergedRange.IsAnyCellMerged)
            {
                throw new ArgumentException("New merged range can't overlap with existing merged range.");
            }
            this.AddInternal(mergedRange);
            CellStyle bordersStyle = new CellStyle();

            ResolveBorder(bordersStyle, mergedRange, IndividualBorder.Top, 0, 0, 0, 1);
            ResolveBorder(bordersStyle, mergedRange, IndividualBorder.Left, 0, 0, 1, 0);
            ResolveBorder(bordersStyle, mergedRange, IndividualBorder.Bottom, mergedRange.Height - 1, 0, 0, 1);
            ResolveBorder(bordersStyle, mergedRange, IndividualBorder.Right, 0, mergedRange.Width - 1, 1, 0);
            bool      flag  = false;
            CellStyle style = null;

            foreach (ExcelCell cell in mergedRange)
            {
                if (!flag)
                {
                    if (!cell.IsStyleDefault)
                    {
                        style = cell.Style;
                    }
                    flag = true;
                }
                cell.AddToMergedRange(mergedRange);
            }
            if ((mergedRange.Value == null) && (style != null))
            {
                mergedRange.Style = style;
            }
            mergedRange.Style.Borders = bordersStyle.Borders;
        }
Пример #3
0
 internal void Remove(MergedCellRange mergedRange)
 {
     this.items.Remove(mergedRange);
     foreach (ExcelCell cell in mergedRange)
     {
         cell.RemoveFromMergedRange();
     }
 }
Пример #4
0
        internal void RemoveFromMergedRange()
        {
            MergedCellRange cellValue = this.cellValue as MergedCellRange;

            if (cellValue == null)
            {
                throw new Exception("Internal error: cell is not merged.");
            }
            this.cellValue = cellValue.ValueInternal;
            this.style     = cellValue.Style;
        }
Пример #5
0
 internal void AddToMergedRange(MergedCellRange mergedRange)
 {
     if ((mergedRange.Value == null) && (this.cellValue != null))
     {
         mergedRange.ValueInternal = this.cellValue;
         if ((this.style != null) && !this.style.IsDefault)
         {
             mergedRange.Style = this.style;
         }
     }
     this.AddToMergedRangeInternal(mergedRange);
 }
Пример #6
0
        public override void SetBorders(MultipleBorders multipleBorders, Color lineColor, LineStyle lineStyle)
        {
            MergedCellRange mergedRange = this.MergedRange;

            if (mergedRange != null)
            {
                mergedRange.SetBorders(multipleBorders, lineColor, lineStyle);
            }
            else
            {
                for (int i = this.firstRow; i <= this.lastRow; i++)
                {
                    for (int j = this.firstColumn; j <= this.lastColumn; j++)
                    {
                        MultipleBorders borders = multipleBorders;
                        if (i < this.lastRow)
                        {
                            borders &= ~MultipleBorders.Bottom;
                        }
                        if (i > this.firstRow)
                        {
                            borders &= ~MultipleBorders.Top;
                        }
                        if (j < this.lastColumn)
                        {
                            borders &= ~MultipleBorders.Right;
                        }
                        if (j > this.firstColumn)
                        {
                            borders &= ~MultipleBorders.Left;
                        }
                        base.Parent.Rows[i].AllocatedCells[j].SetBorders(borders, lineColor, lineStyle);
                    }
                }
            }
        }
Пример #7
0
 internal MergedCellRange(ExcelWorksheet parent, MergedCellRange sourceMRange) : base(parent, sourceMRange.FirstRowIndex, sourceMRange.FirstColumnIndex, sourceMRange.LastRowIndex, sourceMRange.LastColumnIndex)
 {
     this.cellValue = sourceMRange.ValueInternal;
     this.Style     = sourceMRange.Style;
 }
Пример #8
0
 internal void AddToMergedRangeInternal(MergedCellRange mergedRange)
 {
     this.cellValue = mergedRange;
 }
Пример #9
0
 internal void AddInternal(MergedCellRange mergedRange)
 {
     this.items.Add(mergedRange, mergedRange);
 }