/// <summary> /// Private ctor. Prevents public construction.<br/> /// Loads the model from the supplied <see cref="DefinedName"/> /// </summary> /// <param name="wb">The workbool</param> /// <param name="definedName">The named range</param> private DefinedNameModel(Workbook wb, DefinedName definedName) { this.IsDefined = wb.BreakDownDefinedName(definedName, ref worksheetName, ref rowStart, ref rowEnd, ref colStart, ref colEnd); if (this.IsDefined) { var wsPart = wb.GetWorksheetPartByName(worksheetName); this.Worksheet = wsPart.Worksheet; this.SheetData = this.Worksheet.GetFirstChild <SheetData>(); //get cells to be cloned according to the specified rows and columns this.Cells = this.SheetData.Descendants <DocumentFormat.OpenXml.Spreadsheet.Cell>().Where(c => CellExtensions.GetRowIndex(c.CellReference) >= rowStart && CellExtensions.GetRowIndex(c.CellReference) <= rowEnd && CellExtensions.GetColumnIndex(c.CellReference) >= colStart && CellExtensions.GetColumnIndex(c.CellReference) <= colEnd) .ToList <DocumentFormat.OpenXml.Spreadsheet.Cell>(); } }