You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* @param columns comma separated list of Excel column letters and column ranges (e.g. “A:E” or “A,C,E:F”)
142
+
* @param skipRows number of rows before header
143
+
* @param rowsCount number of rows to read.
144
+
*/
104
145
publicfun DataFrame.Companion.readExcel(
105
146
sheet:Sheet,
106
147
columns:String? = null,
148
+
skipRows:Int = 0,
107
149
rowsCount:Int? = null
108
150
): AnyFrame {
109
151
val columnIndexes =if (columns !=null) {
@@ -119,16 +161,16 @@ public fun DataFrame.Companion.readExcel(
119
161
sheet.getRow(0).map { it.columnIndex }
120
162
}
121
163
122
-
val headerRow = sheet.getRow(0)
123
-
val valueRows = sheet.drop(1).let { if (rowsCount !=null) it.take(rowsCount) else it }
164
+
val headerRow = sheet.getRow(skipRows)
165
+
val valueRows = sheet.drop(1+ skipRows).let { if (rowsCount !=null) it.take(rowsCount) else it }
124
166
val columns = columnIndexes.map { index ->
125
167
val headerCell = headerRow.getCell(index)
126
168
val name =if (headerCell?.cellType ==CellType.NUMERIC) {
127
169
headerCell.numericCellValue.toString() // Support numeric-named columns
128
170
} else {
129
171
headerCell?.stringCellValue ?:CellReference.convertNumToColString(index) // Use Excel column names if no data
130
172
}
131
-
val values = valueRows.map {
173
+
val values:List<Any?>= valueRows.map {
132
174
val cell:Cell?= it.getCell(index)
133
175
when (cell?.cellType) {
134
176
CellType._NONE-> error("Cell ${cell.address} of sheet ${sheet.sheetName} has a CellType that should only be used internally. This is a bug, please report https://github.com/Kotlin/dataframe/issues")
0 commit comments