public static ExcelElement <Column>[] GetHeaders(this ExcelElement <Row> row)
        {
            if (row.IsEmpty())
            {
                return(Array.Empty <ExcelElement <Column> >());
            }

            var cells   = row.GetRowCells();
            var headers = cells.Select(cell => new ExcelElement <Column>(row.Doc, new Column(cell))).ToArray();

            return(headers);
        }
        public static ExcelElement <Cell>[] GetRowCells(this ExcelElement <Row> row)
        {
            if (row.IsEmpty())
            {
                return(Array.Empty <ExcelElement <Cell> >());
            }

            var cells    = row.Data.Descendants <Cell>();
            var rowCells = cells.Select(cell => new ExcelElement <Cell>(row.Doc, cell)).ToArray();

            return(rowCells);
        }
        /// <summary>
        /// Maps rows to entities with specified <paramref name="parserProvider"/>.
        /// </summary>
        /// <typeparam name="T">Entity type.</typeparam>
        /// <param name="sheet">Sheet.</param>
        /// <param name="parserProvider"><see cref="IParserProvider"/>.</param>
        /// <param name="factory">Factory.</param>
        /// <returns>Enumeration of <typeparamref name="T"/>.</returns>
        public static IEnumerable <T> GetRowsAs <T>(
            this ExcelElement <Sheet> sheet,
            IParserProvider parserProvider,
            Func <IReadOnlyList <IPropertyValue>, T> factory = null)
        {
            if (factory == null)
            {
                factory = list => (T)Activator.CreateInstance(typeof(T), list);
            }

            if (sheet.IsEmpty())
            {
                return(Array.Empty <T>());
            }

            return(sheet
                   .GetRows()
                   .MapRows(parserProvider, factory));
        }
        public static string[] GetRowValues(
            this ExcelElement <Row> row,
            ExcelElement <Column>[] headers,
            IParserProvider parserProvider,
            string nullValue = null)
        {
            if (row.IsEmpty())
            {
                return(Array.Empty <string>());
            }

            var cells = row.GetRowCells();

            string[] rowValues = new string[headers.Length];
            for (int i = 0; i < headers.Length; i++)
            {
                var header = headers[i];
                // Find cell for the same column.
                var cell = cells.FirstOrDefault(c => c.Data.CellReference.GetColumnReference() == header.Data.ColumnReference);

                if (cell != null)
                {
                    // Set propertyParser for cell according column name
                    var propertyParser = parserProvider.GetParsers().FirstOrDefault(parser => parser.SourceName == header.Data.Name);
                    if (propertyParser != null)
                    {
                        cell.SetMetadata(propertyParser);
                    }

                    rowValues[i] = cell.GetCellValue(nullValue);
                }
                else
                {
                    rowValues[i] = nullValue;
                }
            }

            return(rowValues);
        }