private static void applyAggregateFunction(PropertyInfo property, ColumnAttributes columnAttributes) { var aggregateFunction = property.GetAggregateFunctionAttribute(); if (aggregateFunction != null) columnAttributes.AggregateFunction = new AggregateProvider(aggregateFunction.Value); if (columnAttributes.AggregateFunction == null) { var customAggregateFunction = property.GetPdfRptColumnCustomAggregateFunctionAttribute(); if (customAggregateFunction != null) columnAttributes.AggregateFunction = Activator.CreateInstance(customAggregateFunction) as IAggregateFunction; } }
private static void applyCalculatedField(PropertyInfo property, ColumnAttributes columnAttributes, FieldInfo[] fieldsInfo) { var isCalculatedField = property.GetColumnIsCalculatedFieldAttribute(); if (isCalculatedField != null) columnAttributes.IsCalculatedField = isCalculatedField.Value; if (columnAttributes.IsCalculatedField) { var calculatedFieldFormula = fieldsInfo.GetCalculatedFieldFormulaAttribute(property.Name); if (calculatedFieldFormula != null) columnAttributes.CalculatedFieldFormula = calculatedFieldFormula; } }
private static void applyColumnIsVisible(PropertyInfo property, ColumnAttributes columnAttributes) { var isVisible = property.GetColumnIsVisibleAttribute(); if (isVisible.HasValue) columnAttributes.IsVisible = isVisible.Value; }
private static void applyCellsHorizontalAlignment(PropertyInfo property, ColumnAttributes columnAttributes) { var cellsHorizontalAlignment = property.GetCellsHorizontalAlignmentAttribute(); if (cellsHorizontalAlignment != null) columnAttributes.CellsHorizontalAlignment = cellsHorizontalAlignment.Value; }
private static void applyWidth(PropertyInfo property, ColumnAttributes columnAttributes) { var columnWidth = property.GetColumnWidthAttribute(); if (columnWidth != null) columnAttributes.Width = columnWidth.Value; }
private static void applyPropertyName(PropertyInfo property, ColumnAttributes columnAttributes, bool areColumnsAdHoc) { if (columnAttributes.HeaderCell == null) columnAttributes.HeaderCell = new HeadingCell(); if (string.IsNullOrEmpty(columnAttributes.HeaderCell.Caption) || areColumnsAdHoc) { var caption = property.GetColumnPropertyNameAttribute(); if (!string.IsNullOrEmpty(caption)) columnAttributes.HeaderCell.Caption = caption; } if (string.IsNullOrEmpty(columnAttributes.HeaderCell.Caption)) columnAttributes.HeaderCell.Caption = property.Name; }
private static void applyOrder(PropertyInfo property, ColumnAttributes columnAttributes) { var order = property.GetColumnOrderAttribute(); if (order != null) columnAttributes.Order = order.Value; }
private bool setColumnAggregateFunc(string columnName, ColumnAttributes colDef) { if (_conventions == null || _conventions.ColumnNamesAggregateFunctions == null) return false; var func = _conventions.ColumnNamesAggregateFunctions.FirstOrDefault(x => x.Key == columnName); if (func.Value == null) return false; colDef.AggregateFunction = func.Value; return true; }
private static void applyIncludedGroupFieldEqualityComparer(PropertyInfo property, ColumnAttributes columnAttributes, FieldInfo[] fieldsInfo) { var includeInGrouping = property.GetColumnIncludeInGroupingAttribute(); if (includeInGrouping.HasValue) columnAttributes.IncludeInGrouping = includeInGrouping.Value; if (columnAttributes.IncludeInGrouping) { var equalityComparer = fieldsInfo.GetIncludedGroupFieldEqualityComparerAttribute(property.Name); if (equalityComparer != null) columnAttributes.IncludedGroupFieldEqualityComparer = equalityComparer; } }
private static void applyFixedHeight(PropertyInfo property, ColumnAttributes columnAttributes) { var fixedHeight = property.GetFixedHeightAttribute(); if (fixedHeight.HasValue) columnAttributes.FixedHeight = fixedHeight.Value; }
private static void applyDataFormatString(PropertyInfo property, ColumnAttributes columnAttributes) { var dataFormatString = property.GetDataFormatStringAttribute(); if (!string.IsNullOrEmpty(dataFormatString)) { columnAttributes.ColumnItemsTemplate.BasicProperties.DisplayFormatFormula = data => string.Format(CultureInfo.InvariantCulture, dataFormatString, data); if (columnAttributes.AggregateFunction != null) columnAttributes.AggregateFunction.DisplayFormatFormula = data => string.Format(CultureInfo.InvariantCulture, dataFormatString, data); } }
// Private Methods (1) private static void checkProperty(int columnNumber, ColumnAttributes col) { if (col == null) throw new ArgumentNullException("col"); if (string.IsNullOrEmpty(col.PropertyName)) { throw new InvalidOperationException(string.Format(CultureInfo.InvariantCulture, "pdfColumnsDefinitions[{0}].PropertyName is empty.", columnNumber)); } }
private void setHorizontalAlignment(ColumnAttributes item) { if (item.CellsHorizontalAlignment == null) item.CellsHorizontalAlignment = HorizontalAlignment.Center; _worksheet.Cells[_row, _col].Style.HorizontalAlignment = _horizontalAlignment[item.CellsHorizontalAlignment.Value]; _worksheet.Cells[_row, _col].Style.Font.Bold = true; }
// Public Methods (1) /// <summary> /// Creates PdfColumnDefinitions list based on the PdfRptAdHocColumnsConventions /// </summary> /// <returns>PdfColumnDefinitions list</returns> public IList<ColumnAttributes> CreatePdfColumnDefinitions() { var result = new List<ColumnAttributes>(); if (_bodyDataSource == null || !_bodyDataSource.Rows().Any()) { result.Add(getRowNoCol()); return result; } tryShowRowNumberColumn(result); var firstRowCells = _bodyDataSource.Rows().FirstOrDefault(); if (firstRowCells == null) { result.Add(getRowNoCol()); return result; } var order = 2; foreach (var cellData in firstRowCells) { Type type = null; if (cellData.PropertyValue != null) type = cellData.PropertyValue.GetType(); if (type != null && type.BaseType == typeof(MulticastDelegate)) continue; var itemsTemplate = getColumnItemsTemplate(cellData.PropertyName, type); if (itemsTemplate.BasicProperties == null) itemsTemplate.BasicProperties = new CellBasicProperties(); setDisplayFormatFormula(cellData.PropertyName, type, itemsTemplate); var colDef = new ColumnAttributes { HeaderCell = new HeadingCell { Caption = cellData.PropertyName }, ColumnItemsTemplate = itemsTemplate, Width = 1, PropertyName = cellData.PropertyName, IsVisible = true, Order = order++, CellsHorizontalAlignment = HorizontalAlignment.Center }; setAggregateFunc(cellData.PropertyName, colDef, type); result.Add(colDef); } if (!result.Any()) { result.Add(getRowNoCol()); } return result; }
private static void applyColumnItemsTemplate(PropertyInfo property, ColumnAttributes columnAttributes) { var columnItemsTemplateType = property.GetPdfRptColumnTemplateAttribute(); if (columnItemsTemplateType != null) columnAttributes.ColumnItemsTemplate = Activator.CreateInstance(columnItemsTemplateType) as IColumnItemsTemplate; }
private static void applyMinimumHeight(PropertyInfo property, ColumnAttributes columnAttributes) { var minimumHeight = property.GetMinimumHeightAttribute(); if (minimumHeight.HasValue) columnAttributes.MinimumHeight = minimumHeight.Value; }
private void updateAggregates(ColumnAttributes col, CellAttributes cell) { if (cell == null || col.AggregateFunction == null) return; col.AggregateFunction.CellAdded(cell.RowData.Value, CurrentRowInfoData.IsNewGroupStarted); var columnRowSummary = new SummaryCellData { CellData = new CellData { PropertyName = col.PropertyName, PropertyValue = cell.RowData.Value }, GroupAggregateValue = FuncHelper.ApplyFormula(col.AggregateFunction.DisplayFormatFormula, col.AggregateFunction.GroupValue), GroupRowNumber = CurrentRowInfoData.LastGroupRowNumber, OverallAggregateValue = FuncHelper.ApplyFormula(col.AggregateFunction.DisplayFormatFormula, col.AggregateFunction.OverallValue), OverallRowNumber = CurrentRowInfoData.LastOverallDataRowNumber, GroupNumber = CurrentRowInfoData.LastGroupNumber }; SharedData.ColumnCellsSummaryData.Add(columnRowSummary); }
private void setAggregateFunc(string columnName, ColumnAttributes colDef, Type type) { if (setColumnAggregateFunc(columnName, colDef)) return; if (_conventions == null || _conventions.TypesAggregateFunctions == null || type == null) return; var func = _conventions.TypesAggregateFunctions.FirstOrDefault(x => x.Key == type); if (func.Value != null) { colDef.AggregateFunction = func.Value; } }