Example #1
0
        public object[][] ReadRange(string startCell, string endCell)
        {
            int startRow    = worksheet.GetRowIndex(startCell);
            int startColumn = worksheet.GetCellIndex(startCell);
            int endRow      = worksheet.GetRowIndex(endCell);
            int endColumn   = worksheet.GetCellIndex(endCell);

            if (startRow > endRow)
            {
                throw new ArgumentException("StartCellAddress is not allowed to large than EndCellAddress!");
            }
            object[][] data = new object[endRow = startRow + 1][];
            for (int i = startRow; i < endColumn; i++)
            {
                data[i - startRow] = new object[endColumn - startColumn + 1];
                for (int j = startColumn; j < endColumn + 1; j++)
                {
                    data[i - startRow][j - startColumn] = GetCellValue(i, j);
                }
            }
            return(data);
        }