public TemplateDefinitionPart(TemplateDefinitionPartType partType) { HasLinkedTemplates = false; BindingParts = new List <IDefinitionPart>(); LinkedTemplates = new List <ILinkedTemplateDefinition>(); BindingDefinitions = new List <IBindingDefinition>(); FilterDefinitions = new List <BindingFilterDefinition>(); PartType = partType; }
//@@/// <summary> If a expandable header is defined, contains the binding excelTemplateDefinition used to manage the 'Expand' property of the template (needs a header defined on the template.</summary> //public IBindingDefinition ExpanderBindingDefinition //{ get; set; } #endregion #region .ctors public ExcelTemplateDefinitionPart(ExcelTemplateDefinition parent, TemplateDefinitionPartType partType, ExcelInterop.Range firstRange, ExcelInterop.Range lastRange) : base(partType) { Parent = parent; DefinitionFirstCell = firstRange; DefinitionLastCell = lastRange; Width = DefinitionLastCell.Column - DefinitionFirstCell.Column + 1; Height = DefinitionLastCell.Row - DefinitionFirstCell.Row + 1; if (Width == 0 || Height == 0) { throw new System.Exception("A template part ('Header','Body' or 'Footer' must have a 'Height' and a 'Width' >= 1"); } ExcelInterop.Range templateRange = DefinitionFirstCell; DefinitionCells = DefinitionFirstCell = templateRange.Cells[1, 1]; DefinitionCells = templateRange.Resize[Height, Width]; DefinitionParts = new IDefinitionPart[Height, Width]; PositionLinkedTemplates = new List <List <int> >(); }
private ExcelTemplateDefinitionPart Execute(ExcelTemplateDefinition excelTemplateDefinition, TemplateDefinitionPartType partType, ExcelInterop.Range firstRange, ExcelInterop.Range lastRange) { ExcelTemplateDefinitionPart part = new ExcelTemplateDefinitionPart(excelTemplateDefinition, partType, firstRange, lastRange); for (int rowId = 0; rowId < part.DefinitionCells.Rows.Count; rowId++) { List <int> posLinks = null; ExcelInterop.Range row = part.DefinitionCells.Rows[rowId + 1]; for (int cellId = 0; cellId < row.Cells.Count; cellId++) { ExcelInterop.Range cell = row.Cells[cellId + 1]; IDefinitionPart definitionPart = AnalyzeCell(part, cell); part.DefinitionParts[rowId, cellId] = definitionPart; if (definitionPart is LinkedTemplateDefinition) { if (posLinks == null) { posLinks = new List <int>(); } posLinks.Add(cellId); } if (definitionPart is IBindingDefinition) { if (((IBindingDefinition)definitionPart).IsMultiLine) { part.ContainMultiLinesCells = true; } if (((IBindingDefinition)definitionPart).OnAfterRendering != null) { if (part.OnAfterRendering == null) { part.OnAfterRendering = new List <EventCallback>(); } part.OnAfterRendering.Add(((IBindingDefinition)definitionPart).OnAfterRendering); } } } part.PositionLinkedTemplates.Add(posLinks); } return(part); }
public static ExcelTemplateDefinitionPart CreateInstance(ExcelTemplateDefinition excelTemplateDefinition, TemplateDefinitionPartType partType, ExcelInterop.Range firstRange, ExcelInterop.Range lastRange) { ExcelTemplateDefinitionPartFactory factory = new ExcelTemplateDefinitionPartFactory(); return(factory.Execute(excelTemplateDefinition, partType, firstRange, lastRange)); }