예제 #1
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 style1 = new CellStyle();

            MergedCellRanges.ResolveBorder(style1, mergedRange, IndividualBorder.Top, 0, 0, 0, 1);
            MergedCellRanges.ResolveBorder(style1, mergedRange, IndividualBorder.Left, 0, 0, 1, 0);
            MergedCellRanges.ResolveBorder(style1, mergedRange, IndividualBorder.Bottom, mergedRange.Height - 1, 0, 0, 1);
            MergedCellRanges.ResolveBorder(style1, mergedRange, IndividualBorder.Right, 0, mergedRange.Width - 1, 1, 0);
            bool      flag1  = false;
            CellStyle style2 = null;

            foreach (ExcelCell cell1 in mergedRange)
            {
                if (!flag1)
                {
                    if (!cell1.IsStyleDefault)
                    {
                        style2 = cell1.Style;
                    }
                    flag1 = true;
                }
                cell1.AddToMergedRange(mergedRange);
            }
            if ((mergedRange.Value == null) && (style2 != null))
            {
                mergedRange.Style = style2;
            }
            mergedRange.Style.Borders = style1.Borders;
        }
예제 #2
0
 internal void Remove(MergedCellRange mergedRange)
 {
     this.items.Remove(mergedRange);
     foreach (ExcelCell cell1 in mergedRange)
     {
         cell1.RemoveFromMergedRange();
     }
 }
예제 #3
0
        internal void RemoveFromMergedRange()
        {
            MergedCellRange range1 = this.cellValue as MergedCellRange;

            if (range1 == null)
            {
                throw new Exception("Internal error: cell is not merged.");
            }
            this.cellValue = range1.ValueInternal;
            this.style     = range1.Style;
        }
예제 #4
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);
 }
예제 #5
0
        private static void ResolveBorder(CellStyle bordersStyle, MergedCellRange mergedRange, IndividualBorder borderId, int row, int column, int rowInc, int colInc)
        {
            CellBorder border1 = bordersStyle.Borders[borderId];
            bool       flag1   = true;

            while ((row < mergedRange.Height) && (column < mergedRange.Width))
            {
                CellBorder border2 = mergedRange[row, column].Style.Borders[borderId];
                if (flag1)
                {
                    border1.LineStyle = border2.LineStyle;
                    border1.LineColor = border2.LineColor;
                    flag1             = false;
                }
                else if ((border2.LineStyle != border1.LineStyle) || (border2.LineColor != border1.LineColor))
                {
                    border1.LineStyle = LineStyle.None;
                    border1.LineColor = Color.Empty;
                    return;
                }
                row    += rowInc;
                column += colInc;
            }
        }
예제 #6
0
 internal void AddToMergedRangeInternal(MergedCellRange mergedRange)
 {
     this.cellValue = mergedRange;
 }
예제 #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 AddInternal(MergedCellRange mergedRange)
 {
     this.items.Add(mergedRange, mergedRange);
 }