コード例 #1
0
        public int DoMerge(int currentRowIndex, Range currentCellRange)
        {
            if (currentCellRange == null)
            {
                return(0);
            }
            lastCellRange = currentCellRange;

            return(RangeHelper.MergeRanges(currentCellRange, mOption));
        }
コード例 #2
0
        public void MergeVGroupCells()
        {
            for (int i = 0; i < lineList.Count; i++)
            {
                TplLine line = lineList[i];

                /*
                 * if (!line.containsHGroup)
                 *      continue;
                 */
                int colIndex = line.colIndex;
                for (int j = 0; j < line.cellList.Count; j++)
                {
                    TplCell cell = line.cellList [j];
                    if (cell.mOption != MergeOption.Up ||
                        (cell.align != GroupAlign.none &&
                         cell.align != GroupAlign.always))
                    {
                        colIndex += cell.acrossColumns;
                        continue;
                    }
                    for (int k = 0; k < line.insertedRowList.Count; k++)
                    {
                        int rowIndex = line.insertedRowList[k];

                        CellRange range = RangeHelper.GetCell(tplRange.Worksheet, colIndex, rowIndex);

                        if (!range.HasMerged)
                        {
                            RangeHelper.MergeRanges(range, MergeOption.Up);
                        }
                    }

                    colIndex += cell.acrossColumns;
                }
            }
        }
コード例 #3
0
        public void MergeHGroupCells()
        {
            for (int i = 0; i < lineList.Count; i++)
            {
                TplLine line = lineList [i];
                if (!line.containsHGroup)
                {
                    continue;
                }

                for (int j = 0; j < line.insertedRowList.Count; j++)
                {
                    int rowIndex = line.insertedRowList [j];

                    object lastValue = null;
                    int    colIndex  = dColumn.startColIndex;
                    // if (line.cellList [colIndex].mOption != MergeOption.Left)
                    //	continue ;
                    // ingore this line ;

                    for (int k = 0; k < dColumn.insertCount; k++)
                    {
                        Range  cell  = RangeHelper.GetCell(tplRange.Worksheet, colIndex, rowIndex);
                        object value = cell.Value2;


                        if (lastValue != null &&
                            Equals(lastValue, value))
                        {
                            /* remove after debug.
                             * if (colIndex == 27)
                             *      Console.WriteLine ("colINdex=27");
                             */
                            // clear
                            // judge if last row is last hgrouoped row.
                            if (i == lineList.Count - 1 || lineList [i + 1].containsHGroup)
                            {
                                RangeHelper.MergeRanges(cell, MergeOption.Left);
                            }
                            else
                            {
                                // check is this column first column in hgrouped columns.
                                if (k % dColumn.gCols > 0)
                                {
                                    RangeHelper.MergeRanges(cell, MergeOption.Left);
                                }
                            }
                        }

                        lastValue = value;
                        colIndex++;
                    }

                    // repair unmerged range
                    int afterIndex = dColumn.startCellIndex + dColumn.insertCount;
                    for (int k = afterIndex;
                         k < line.cellList.Count; k++)
                    {
                        TplCell cell = line.cellList [k];

                        if (cell.mOption == MergeOption.Left)
                        {
                            Range range = RangeHelper.GetCell(tplRange.Worksheet, colIndex, rowIndex);
                            RangeHelper.MergeRanges(range, MergeOption.Left);
                        }
                        colIndex += cell.acrossColumns;
                    }
                }
            }
        }