protected override IExcelPanel CopyPanel(IXLCell cell) { IXLRange newRange = ExcelHelper.CopyRange(Range, cell); var panel = new ExcelDataItemPanel(newRange, _report, _templateProcessor); FillCopyProperties(panel); return(panel); }
private ExcelDataItemPanel CreateTemplatePanel() { var templatePanel = new ExcelDataItemPanel(Range, _report, _templateProcessor) { Parent = Parent, Children = Children, RenderPriority = RenderPriority, ShiftType = ShiftType, Type = Type, BeforeRenderMethodName = BeforeDataItemRenderMethodName, AfterRenderMethodName = AfterDataItemRenderMethodName, }; foreach (IExcelPanel child in templatePanel.Children) { child.Parent = templatePanel; } return(templatePanel); }
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); // Removing the template if there are no data if (enumerator == null || enumerator.RowCount == 0) { DeletePanel(this); return; } // Creating the panel template which will be replicated then ExcelDataItemPanel templatePanel = CreateTemplatePanel(); _templatePanelRowCount = templatePanel.Range.RowCount(); _templatePanelColumnCount = templatePanel.Range.ColumnCount(); // Allocating space for data if (enumerator.RowCount > 1) { AllocateSpaceForData(templatePanel, enumerator.RowCount); } int rowNum = 0; while (enumerator.MoveNext()) { object currentItem = enumerator.Current; ExcelDataItemPanel currentPanel; if (rowNum != enumerator.RowCount - 1) { IXLCell templateFirstCell = templatePanel.Range.FirstCell(); // The template itself is moved down or right, depending on the type of panel MoveTemplatePanel(templatePanel); // Copying the template on its previous place for the panel which the current data item will be rendered in currentPanel = (ExcelDataItemPanel)templatePanel.Copy(templateFirstCell); } else { // Rendering data directly in the template if there is the last data item currentPanel = templatePanel; } currentPanel.DataItem = new HierarchicalDataItem { Value = currentItem, Parent = parentDataItem }; // Fill template with data currentPanel.Render(); ResultRange = ExcelHelper.MergeRanges(ResultRange, currentPanel.ResultRange); RemoveAllNamesRecursive(currentPanel); rowNum++; } RemoveName(); } finally { (enumerator as IDisposable)?.Dispose(); } GroupResult(); CallAfterRenderMethod(); }