예제 #1
0
        /// <summary>
        ///     Read virtual table from epplus worksheet
        /// </summary>
        /// <param name="worksheet"></param>
        /// <param name="startRowIndex">
        ///     1-based index (1..1048576) of the row containing data (not header), inclusive
        /// </param>
        /// <param name="endRowIndex">
        ///     Optional 1-based index (1..1048577), exclusive to allow reading empty table
        /// </param>
        /// <param name="columns">
        ///     Pairs of name and 1-based index.
        /// </param>
        public ExcelTableReader(ExcelWorksheet worksheet, int startRowIndex, int?endRowIndex, IList <KeyValuePair <string, int> > columns)
        {
            Check.DoRequireArgumentNotNull(worksheet, nameof(worksheet));
            Check.DoRequireArgumentNotNull(columns, nameof(columns));

            _columnNames = columns.OrderBy(p => p.Value).Select(p => p.Key).ToList();
            var columnNameIndex = columns.ToDictionary(p => p.Key, p => p.Value);

            Rows = new ExcelTableRowReaderCollection(startRowIndex, endRowIndex, worksheet, columnNameIndex);
        }
예제 #2
0
        /// <param name="excelTable">
        ///     Mandatory
        /// </param>
        public ExcelTableReader(ExcelTable excelTable)
        {
            Check.DoRequireArgumentNotNull(excelTable, nameof(excelTable));

            _columnNames = excelTable.Columns.Select(c => c.Name).ToList();
            var columnNameIndex = excelTable.Columns.ToDictionary(c => c.Name, c => c.Position + excelTable.Address.Start.Column);

            var startRow = excelTable.Address.Start.Row;

            if (excelTable.ShowHeader)
            {
                ++startRow;
            }

            Rows = new ExcelTableRowReaderCollection(startRow, excelTable.Address.End.Row, excelTable.WorkSheet, columnNameIndex);
        }