Пример #1
0
        private void addTableRow(IList <CellData> rowData, BaseColor backgroundColor, BaseColor foreColor)
        {
            var finalRowDataList = new List <CellData>();

            for (var columnNumber = 0; columnNumber < SharedData.ColumnsCount; columnNumber++)
            {
                var            col = SharedData.PdfColumnsAttributes[columnNumber];
                CellAttributes cell;
                if (col.IsRowNumber)
                {
                    cell = TableCellHelper.AddRowNumberCell(backgroundColor, foreColor, columnNumber);
                }
                else
                {
                    GroupsManager.ModifyRowData(rowData);
                    cell = TableCellHelper.AddRowCell(rowData, backgroundColor, foreColor, columnNumber);
                    updateAggregates(col, cell);
                }

                finalRowDataList.Add(new CellData
                {
                    PropertyName   = col.PropertyName,
                    PropertyValue  = cell.RowData.Value,
                    FormattedValue = cell.RowData.FormattedValue,
                    PropertyType   = cell.RowData.PropertyType
                });
            }

            _exporterManager.ApplyExporter(finalRowDataList, CurrentRowInfoData);
            CurrentRowInfoData.IsNewGroupStarted    = false;
            CurrentRowInfoData.PreviousTableRowData = rowData;
        }
Пример #2
0
        private IList <BaseColor> applyRowSettings(IList <CellData> row)
        {
            if (_setNumberOfRowsPerPageNeedsNewPage)
            {
                SharedData.PdfDoc.NewPage();
            }

            var backColor = CurrentRowInfoData.LastOverallDataRowNumber % 2 != 0 ? SharedData.Template.RowBackgroundColor : SharedData.Template.AlternatingRowBackgroundColor;
            var foreColor = CurrentRowInfoData.LastOverallDataRowNumber % 2 != 0 ? SharedData.Template.RowFontColor : SharedData.Template.AlternatingRowFontColor;

            CurrentRowInfoData.LastOverallDataRowNumber++;
            CurrentRowInfoData.LastGroupRowNumber++;

            if (GroupsManager.ShouldStartNewGroup(row))
            {
                GroupsManager.StartNewGroup(row, !_setNumberOfRowsPerPageNeedsNewPage);
            }
            else
            {
                if (CurrentRowInfoData.LastOverallDataRowNumber == 1)
                {
                    TableInitAddHeaderAndFooter();
                }
            }

            return(new List <BaseColor> {
                backColor, foreColor
            });
        }
Пример #3
0
        /// <summary>
        /// Finalizing the MainTable's rendering
        /// </summary>
        public void CloseMainTable()
        {
            if (_dataSourceIsEmpty)
            {
                if (SharedData.MainTableEvents != null)
                {
                    SharedData.MainTableEvents.MainTableAdded(new EventsArguments {
                        PdfDoc = SharedData.PdfDoc, PdfWriter = SharedData.PdfWriter, Table = MainTable, ColumnCellsSummaryData = SharedData.ColumnCellsSummaryData, PreviousTableRowData = _previousTableRowData, PageSetup = SharedData.PageSetup, PdfFont = SharedData.PdfFont, PdfColumnsAttributes = SharedData.PdfColumnsAttributes
                    });
                }
                return;
            }

            MainTable.ElementComplete = true; //print the last footer
            if (SharedData.ShouldWrapTablesInColumns)
            {
                MainGroupTable.AddCell(new PdfPCell(MainTable)
                {
                    Border = 0
                });
                MainGroupTable.AddCell(new PdfPCell(TableHelper.CreateEmptyRowTable(fixedHeight: 30))
                {
                    Border = 0
                });

                GroupsManager.AddAllGroupsSummary();

                new TablesInColumns
                {
                    PdfDoc             = SharedData.PdfDoc,
                    PdfWriter          = SharedData.PdfWriter,
                    PageSetup          = SharedData.PageSetup,
                    CurrentRowInfoData = CurrentRowInfoData
                }.Wrap(MainGroupTable);
            }
            else
            {
                MainTable.SpacingAfter += MainTable.HeaderHeight + 2.5f;
                tryFitToContent();
                SharedData.PdfDoc.Add(MainTable);

                var lastRow = SharedData.ColumnCellsSummaryData.OrderByDescending(x => x.OverallRowNumber).FirstOrDefault();
                if (lastRow != null)
                {
                    CurrentRowInfoData.LastRenderedRowNumber = lastRow.OverallRowNumber;
                }

                GroupsManager.AddAllGroupsSummary();
            }

            if (MainTable.Rows.Count > 0)
            {
                MainTable.DeleteBodyRows();
            }
            mainTableAdded();
        }
        private void initManagers()
        {
            _groupsManager = new GroupsManager
            {
                SharedData         = _commonManagersInfoData,
                InitTable          = _initTable,
                MainTable          = _mainTable,
                CurrentRowInfoData = CurrentRowInfoData,
                TableCellHelper    = _tableCellHelper,
                MainGroupTable     = _mainGroupTable
            };

            _rowsManager = new RowsManager
            {
                SharedData         = _commonManagersInfoData,
                TableCellHelper    = _tableCellHelper,
                MainTable          = _mainTable,
                GroupsManager      = _groupsManager,
                MainGroupTable     = _mainGroupTable,
                CurrentRowInfoData = CurrentRowInfoData
            };

            _groupsManager.RowsManager = _rowsManager;
        }