예제 #1
0
        public static string[] GetHeaderValues(this ExcelListObjectHeaderRange range)
        {
            object[,] allHeaderValues = range.GetInteropVersion().Value2;
            List <string> result = new List <string>();

            for (int i = 1; i <= allHeaderValues.GetLength(1); i++)
            {
                result.Add(allHeaderValues[1, i].ToString());
            }
            return(result.ToArray());
        }
예제 #2
0
        public static ExcelRange GetExcelRangeFor(this ExcelListObjectHeaderRange range, string startColumn, string endColumn)
        {
            var       baseColumnIndex  = range.GetInteropVersion().Column;
            var       baseRowIndex     = range.GetInteropVersion().Row;
            var       startColumnIndex = range.GetIndexForColumn(startColumn) + baseColumnIndex;
            var       endColumnIndex   = range.GetIndexForColumn(endColumn) + baseColumnIndex;
            Worksheet worksheet        = range.GetInteropVersion().Worksheet;
            Range     startCell        = worksheet.Cells[baseRowIndex, startColumnIndex];
            Range     endCell          = worksheet.Cells[baseRowIndex, endColumnIndex];

            return(new ExcelRange((Range)worksheet.get_Range(startCell, endCell)));
        }
예제 #3
0
 public static int GetIndexForColumn(this ExcelListObjectHeaderRange headerRange, string columnName)
 {
     return(headerRange.GetHeaderValues().ToList().IndexOf(columnName));
 }