コード例 #1
0
            //переписать с кроулингом, рассмотреть вопрос: ***xx----
            //                                             xxxxx--**
            private void drawHeaderGroup(HeaderGroup group, int lineNum)
            {
                var  colIndexes     = group.colNumbers.OrderBy(x => x).ToArray();
                int  left           = colIndexes[0];
                bool is_margin_left = true;

                for (int i = 0; i < colIndexes.Length; i++)
                {
                    if (i > 0 && colIndexes[i] - colIndexes[i - 1] != 1)
                    {
                        rng(lineNum, left, lineNum, colIndexes[i - 1]).Merge();

                        group.Format(rng(lineNum, left, lineNum, colIndexes[i - 1]));
                        if (is_margin_left)
                        {
                            rng(lineNum, left).Value = group.Caption;
                            is_margin_left           = false;
                        }
                        left = colIndexes[i];
                    }
                }

                rng(lineNum, left, lineNum, colIndexes[colIndexes.Length - 1]).Merge();
                group.Format(rng(lineNum, left, lineNum, colIndexes[colIndexes.Length - 1]));
                if (is_margin_left)
                {
                    rng(lineNum, left).Value = group.Caption;
                }
            }
コード例 #2
0
            private void drawHeader(Column column, int lastLineNum, int colNum)
            {
                //if (colNum != 1) return;
                var Filler = new CrawlingObject();

                for (int i = 0; i <= lastDrawnNumber; i++)
                {
                    HeaderGroup lvl = null;
                    if (this.headerGroups != null)
                    {
                        lvl = this.headerGroups.Where(x => (x.level == i + 1) && (x.colNumbers.Contains(colNum))).FirstOrDefault();
                    }

                    if (lvl == null)
                    {
                        if (Filler.lastValue != null)
                        {
                            Filler.Break(i, null);
                        }
                        else//if (Filler.lastValue == null)
                        {
                            if (Filler.startPoint == -1)
                            {
                                Filler.Break(i, null);
                            }
                            else
                            {
                                Filler.endPoint++;
                            }
                        }
                    }
                    if (lvl != null)
                    {
                        if (Filler.lastValue == null && Filler.startPoint != -1)
                        {
                            rng(Filler.startPoint, colNum, Filler.endPoint, colNum).Merge();
                            column.Format(rng(Filler.startPoint, colNum, Filler.endPoint, colNum));
                            Filler.Break(i, lvl);
                        }
                        else
                        {
                            Filler.Break(i, lvl);
                        }
                    }
                }

                int top_cell = 0;

                if (this.Settings.BubbleColumnCaptions)
                {
                    if (Filler.startPoint <= lastLineNum)
                    {
                        rng(Filler.startPoint, colNum, lastLineNum, colNum).Merge();
                        column.Format(rng(Filler.startPoint, colNum, lastLineNum, colNum));
                    }

                    top_cell = lastDrawnNumber;

                    if (this.headerGroups != null)
                    {
                        var tmp2 = this.headerGroups.Select(x => new { lvl = x.level, cols = x.colNumbers })
                                   .GroupBy(x => x.lvl, (x, y) => new { lvl = x, contains = y.SelectMany(z => z.cols) })
                                   .ToDictionary(x => x.lvl, (y) => y.contains.ToArray()).OrderBy(x => x.Key);//Where(x => !(x.colNumbers.Contains(colNum))).Select(x => x).ToArray();

                        foreach (var tmp3 in tmp2)
                        {
                            if (!tmp3.Value.Contains(colNum))
                            {
                                top_cell = tmp3.Key - 1; break;
                            }
                        }
                    }
                }
                else
                {
                    rng(Filler.startPoint, colNum, lastDrawnNumber, colNum).Merge();
                    column.Format(rng(Filler.startPoint, colNum, lastDrawnNumber, colNum));

                    if (this.headerGroups != null)
                    {
                        var tmp2 = this.headerGroups.Select(x => new { lvl = x.level, cols = x.colNumbers })
                                   .GroupBy(x => x.lvl, (x, y) => new { lvl = x, contains = y.SelectMany(z => z.cols) })
                                   .ToDictionary(x => x.lvl, (y) => y.contains.ToArray()).OrderByDescending(x => x.Key);

                        top_cell = 0;

                        foreach (var tmp3 in tmp2)
                        {
                            if (tmp3.Value.Contains(colNum))
                            {
                                top_cell = tmp3.Key; break;
                            }                                                                //else ;
                        }
                    }
                }

                rng(top_cell, colNum).Value = column.Caption;
            }