Exemple #1
0
        private void RenderData(BaseJournalRow <TRow> row)
        {
            _writer.WriteStartElement("Row");
            if (_journalControl.Journal.RowsPropertiesDic.ContainsKey(row.RowKey))
            {
                RenderRowsProperties(_journalControl.Journal.RowsPropertiesDic[row.RowKey]);
            }

            MoveRowIndex();
            var cellsPropertiesDic = _journalControl.Journal.CellsPropertiesDic;

            foreach (var cell in row.AllCells)
            {
                var    bCell   = cell.Value as BaseJournalCell;
                string styleId = null;
                if (bCell != null && cellsPropertiesDic.ContainsKey(bCell.GetCellKey()))//достаем стиль
                {
                    styleId = cellsPropertiesDic[bCell.GetCellKey()].StyleId;
                }

                if (styleId == null)//если стиль не был найден используем стандартный
                {
                    if (cell.Key != null && cell.Key.UsingInGroup)
                    {
                        styleId = bCell != null && bCell.IsVertical() ? DataGroupVerticalStyleId : DataGroupStyleId;
                    }
                    else if (bCell != null && bCell.RenderContext.TotalGroupValues != null)
                    {
                        styleId = DataGroupStyleId;
                    }
                    else if (bCell != null && bCell.IsVertical())
                    {
                        styleId = DataVerticalStyleId;
                    }
                    else
                    {
                        styleId = DataStyleId;
                    }
                }
                if (bCell != null)
                {
                    RenderCell(_writer, bCell.GetValue(), bCell.RowSpan, bCell.ColSpan, styleId);
                }
                else
                {
                    RenderCell(_writer, "", 1, 1, styleId);
                }
            }
            _writer.WriteEndElement();
        }
Exemple #2
0
        private void AddStyles(BaseJournalRow <TRow> row)
        {
            var rowProperties = row.RowKey != null && _journalControl.Journal.RowsPropertiesDic.ContainsKey(row.RowKey)
                                    ? _journalControl.Journal.RowsPropertiesDic[row.RowKey]
                                    : null;
            var cellsProperties    = _journalControl.Journal.CellsProperties;
            var cellsPropertiesDic = _journalControl.Journal.CellsPropertiesDic;

            foreach (var cell in row.AllCells)
            {
                var    bCell         = (BaseJournalCell)cell.Value;
                var    hierarchyItem = bCell.RenderContext.ColumnHierarchy;
                string styleId;
                if (cell.Key != null && cell.Key.UsingInGroup)
                {
                    styleId = bCell != null && bCell.IsVertical() ? DataGroupVerticalStyleId : DataGroupStyleId;
                }
                else if (bCell != null && bCell.RenderContext.TotalGroupValues != null)
                {
                    styleId = bCell.Column.ColumnType == ColumnType.Numeric ? DataGroupStyleCenterId : DataGroupStyleId;
                }
                else if (bCell != null && bCell.IsVertical())
                {
                    styleId = DataVerticalStyleId;
                }
                else if (bCell != null && bCell.Column != null && bCell.Column.ColumnType == ColumnType.Numeric)
                {
                    styleId = DataStyleCenterId;
                }
                else
                {
                    styleId = DataStyleId;
                }

                string cellKey = null;
                //todo: реализовать else
                if (bCell != null)
                {
                    cellKey = bCell.GetCellKey();
                }

                // если есть у ячеки ключ
                if (cellKey != null)
                {
                    CellProperties cellProps = null;
                    if (cellsPropertiesDic.ContainsKey(cellKey))
                    {
                        cellProps = cellsPropertiesDic[cellKey];
                    }
                    else if (rowProperties != null || (hierarchyItem != null && (hierarchyItem.BColor != null || hierarchyItem.PColor != null)))
                    {
                        // созадем свйоства для ячейки, если имеются настройки для строки или колонки
                        cellsPropertiesDic[cellKey] = cellProps = new CellProperties {
                            Key = cellKey
                        };
                        cellsProperties.Add(cellProps);
                    }

                    if (cellProps != null)
                    {
                        if (hierarchyItem != null && bCell.ColSpan <= 1)
                        {
                            if (hierarchyItem.BColor != null && cellProps.BColor == null)
                            {
                                cellProps.BColor = hierarchyItem.BColor;
                            }
                            if (hierarchyItem.PColor != null && cellProps.PColor == null)
                            {
                                cellProps.PColor = hierarchyItem.PColor;
                            }
                        }

                        // если есть настройки у строки то передаем их ячейки
                        if (rowProperties != null)
                        {
                            if (cellProps.BColor == null)
                            {
                                cellProps.BColor = rowProperties.BColor;
                            }
                            if (cellProps.PColor == null)
                            {
                                cellProps.PColor = rowProperties.PColor;
                            }
                            if (cellProps.Size == null)
                            {
                                cellProps.Size = rowProperties.Size;
                            }
                            if (cellProps.Bold == null)
                            {
                                cellProps.Bold = rowProperties.Bold;
                            }
                            if (cellProps.Italic == null)
                            {
                                cellProps.Italic = rowProperties.Italic;
                            }
                            if (cellProps.HAligment == null)
                            {
                                cellProps.HAligment = rowProperties.HAligment;
                            }
                        }

                        // если стиль был найден или создан, то проставляем ключ стиля
                        cellProps.StyleId = AddStyle(cellProps, styleId, "Solid").ToString();
                    }
                }
            }
        }
Exemple #3
0
        private void RenderData(BaseJournalRow <TRow> row)
        {
            if (row.RowKey != null && _journalControl.Journal.RowsPropertiesDic.ContainsKey(row.RowKey))
            {
                WriteStartRow(_journalControl.Journal.RowsPropertiesDic[row.RowKey].Height);
            }
            else
            {
                WriteStartRow(null);
            }

            MoveRowIndex();
            var cellsPropertiesDic = _journalControl.Journal.CellsPropertiesDic;

            foreach (var cell in row.AllCells.Where(r => r.Value.Visible))
            {
                var    bCell   = cell.Value as BaseJournalCell;
                string styleId = null;
                if (bCell != null && cellsPropertiesDic.ContainsKey(bCell.GetCellKey())) // достаем стиль
                {
                    styleId = cellsPropertiesDic[bCell.GetCellKey()].StyleId;
                }

                // если стиль не был найден используем стандартный
                if (styleId == null)
                {
                    if (cell.Key != null && cell.Key.UsingInGroup)
                    {
                        styleId = bCell != null && bCell.IsVertical() ? DataGroupVerticalStyleId : DataGroupStyleId;
                    }
                    else if (bCell != null && bCell.RenderContext.TotalGroupValues != null)
                    {
                        styleId = bCell.Column.ColumnType == ColumnType.Numeric ? DataGroupStyleCenterId : DataGroupStyleId;
                    }
                    else if (bCell != null && bCell.IsVertical())
                    {
                        styleId = DataVerticalStyleId;
                    }
                    else if (bCell != null && bCell.Column != null && bCell.Column.ColumnType == ColumnType.Numeric)
                    {
                        styleId = DataStyleCenterId;
                    }
                    else
                    {
                        styleId = DataStyleId;
                    }
                }

                if (bCell != null)
                {
                    string cellData = bCell.GetValue().Replace("&nbsp;", " ");
                    if (!string.IsNullOrEmpty(bCell.RenderContext.ColumnHierarchy.ColumnName) && bCell.RenderContext.GroupValues == null)
                    {
                        StringBuilder sb;
                        if (_columnsAddresses.ContainsKey(bCell.RenderContext.ColumnHierarchy.ColumnName))
                        {
                            sb = _columnsAddresses[bCell.RenderContext.ColumnHierarchy.ColumnName].Append(" ");
                        }
                        else
                        {
                            _columnsAddresses[bCell.RenderContext.ColumnHierarchy.ColumnName] = sb = new StringBuilder();
                        }
                        sb.Append(GetLaterByInt(_columnIndex)).Append(_rowIndex);
                    }

                    var formula     = bCell.RenderContext.GetFormula()?.ToString(_columnIndex, _rowIndex) ?? string.Empty;
                    var rangeOfCell = RenderCell(_writer, cellData, bCell.RowSpan, bCell.ColSpan, styleId, bCell.Column == null ? ColumnType.Other : bCell.Column.ColumnType, formula);
                    if (cell.Key != null && cell.Key.TypeCell == BaseJournalTypeCell.HyperLink && bCell.RenderContext.TotalGroupValues == null)
                    {
                        var href = cell.Key.GetHyperLink(bCell.RenderContext);
                        if (!string.IsNullOrEmpty(href))
                        {
                            AddHyperLink(rangeOfCell, cellData, href);
                        }
                    }
                }
                else
                {
                    RenderCell(_writer, string.Empty, 1, 1, styleId, ColumnType.Other, string.Empty);
                }
            }

            _writer.WriteEndElement();
        }
Exemple #4
0
        private void AddStyles(BaseJournalRow <TRow> row)
        {
            var rowProperties = _journalControl.Journal.RowsPropertiesDic.ContainsKey(row.RowKey)
                ? _journalControl.Journal.RowsPropertiesDic[row.RowKey]
                : null;
            var cellsProperties    = _journalControl.Journal.CellsProperties;
            var cellsPropertiesDic = _journalControl.Journal.CellsPropertiesDic;
            var hierachyColumns    = _journalControl.Journal.InnerHeader.GetDataColumns();
            int i = 0;

            foreach (var cell in row.AllCells)
            {
                var    hierarchyItem = hierachyColumns[i++];
                var    bCell         = cell.Value as BaseJournalCell;
                string styleId;
                if (cell.Key != null && cell.Key.UsingInGroup)
                {
                    styleId = bCell != null && bCell.IsVertical() ? DataGroupVerticalStyleId : DataGroupStyleId;
                }
                else if (bCell != null && bCell.RenderContext.TotalGroupValues != null)
                {
                    styleId = DataGroupStyleId;
                }
                else if (bCell != null && bCell.IsVertical())
                {
                    styleId = DataVerticalStyleId;
                }
                else
                {
                    styleId = DataStyleId;
                }

                string cellKey = null;
                if (bCell != null)
                {
                    cellKey = bCell.GetCellKey();
                }
                else
                {
                    //todo: сделать эту часть
                }
                if (cellKey != null) //если есть у ячеки ключ
                {
                    CellProperties cellProps = null;
                    if (cellsPropertiesDic.ContainsKey(cellKey))
                    {
                        cellProps = cellsPropertiesDic[cellKey];
                    }
                    else if (rowProperties != null || hierarchyItem.BColor != null || hierarchyItem.PColor != null) //созадем свйоства для ячейки, если имеются настройки для строки или колонки
                    {
                        cellsPropertiesDic[cellKey] = cellProps = new CellProperties {
                            Key = cellKey
                        };
                        cellsProperties.Add(cellProps);
                    }
                    if (cellProps != null) //если стиль был найден или создан, то проставляем ключ стиля
                    {
                        if (hierarchyItem.BColor != null && cellProps.BColor == null)
                        {
                            cellProps.BColor = hierarchyItem.BColor;
                        }
                        if (hierarchyItem.PColor != null && cellProps.PColor == null)
                        {
                            cellProps.PColor = hierarchyItem.PColor;
                        }
                        if (rowProperties != null) //если есть настройки у строки то передаем их ячейки
                        {
                            if (cellProps.BColor == null)
                            {
                                cellProps.BColor = rowProperties.BColor;
                            }
                            if (cellProps.PColor == null)
                            {
                                cellProps.PColor = rowProperties.PColor;
                            }
                        }
                        cellProps.StyleId = AddStyle(cellProps.BColor, cellProps.PColor, styleId, "Solid");
                    }
                }
            }
        }