public override void Render() { // Receive parent data item context HierarchicalDataItem parentDataItem = GetDataContext(); _data = _isDataReceivedDirectly ? _data : _templateProcessor.GetValue(_dataSourceTemplate, parentDataItem); bool isCanceled = CallBeforeRenderMethod(); if (isCanceled) { ResultRange = ExcelHelper.CloneRange(Range); return; } ICustomEnumerator enumerator = null; try { enumerator = EnumeratorFactory.Create(_data) ?? new EnumerableEnumerator(new object[] { }); IDictionary <IXLCell, IList <ParsedAggregationFunc> > totalCells = ParseTotalCells(); DoAggregation(enumerator, totalCells.SelectMany(t => t.Value).ToArray(), parentDataItem); IXLWorksheet ws = Range.Worksheet; dynamic dataSource = new ExpandoObject(); var dataSourceAsDict = (IDictionary <string, object>)dataSource; foreach (KeyValuePair <IXLCell, IList <ParsedAggregationFunc> > totalCell in totalCells) { IList <ParsedAggregationFunc> aggFuncs = totalCell.Value; foreach (ParsedAggregationFunc f in aggFuncs) { dataSourceAsDict[$"AggFunc_{f.UniqueName}"] = f.Result; } } string rangeName = $"AggFuncs_{Guid.NewGuid():N}"; Range.AddToNamed(rangeName, XLScope.Worksheet); var dataPanel = new ExcelDataSourcePanel(new[] { dataSource }, ws.NamedRange(rangeName), _report, _templateProcessor) { Parent = Parent }; dataPanel.Render(); ResultRange = ExcelHelper.MergeRanges(Range, dataPanel.ResultRange); } finally { (enumerator as IDisposable)?.Dispose(); } RemoveName(); CallAfterRenderMethod(); }