PdfRpt.Core.PdfTable.TableCellHelper.AddRowCell C# (CSharp) Method

AddRowCell() public method

Adds a new data PdfPCell to the MainTable
public AddRowCell ( IList rowValues, BaseColor backgroundColor, BaseColor foreColor, int columnNumber ) : PdfRpt.Core.Contracts.CellAttributes
rowValues IList
backgroundColor iTextSharp.text.BaseColor
foreColor iTextSharp.text.BaseColor
columnNumber int
return PdfRpt.Core.Contracts.CellAttributes
        public CellAttributes AddRowCell(IList<CellData> rowValues, BaseColor backgroundColor, BaseColor foreColor, int columnNumber)
        {
            var col = SharedData.PdfColumnsAttributes[columnNumber];

            checkProperty(columnNumber, col);

            object data;
            if (col.IsCalculatedField)
            {
                data = FuncHelper.ApplyCalculatedFieldFormula(col.CalculatedFieldFormula, rowValues);
                rowValues.Add(new CellData { PropertyName = col.PropertyName, PropertyValue = data, FormattedValue = data.ToSafeString() });
            }
            else
            {
                CellData pdfCellData;
                if (col.PropertyIndex >= 0)
                {
                    pdfCellData = rowValues.FirstOrDefault(x => x.PropertyName == col.PropertyName && x.PropertyIndex == col.PropertyIndex);
                }
                else
                {
                    pdfCellData = rowValues.FirstOrDefault(x => x.PropertyName == col.PropertyName);
                }

                if (pdfCellData == null)
                {
                    var propertiesList = rowValues.Select(x => x.PropertyName).Aggregate((p1, p2) => p1 + ", " + p2);
                    throw new InvalidOperationException(string.Format(CultureInfo.InvariantCulture,
                        "'{0}' property not found. Available properties list: {1}", col.PropertyName, propertiesList));
                }
                data = pdfCellData.PropertyValue;
            }

            return AddGeneralCell(
                        backgroundColor,
                        foreColor,
                        data,
                        columnNumber,
                        RowType.DataTableRow,
                        CellType.DataTableCell,
                        rowValues,
                        setItemTemplate: true);
        }