konttlin写的解析方法
private fun getXls() {
val asset =resources.assets
val thread = Thread(object : Runnable {
override fun run() {
val inputStream = asset.open("daban.xls")
val book = Workbook.getWorkbook(inputStream)
inputStream.close()
val sheets: Array = book.sheets //xls文件中有多少个sheet
Log.i("aaa", "sheets " + sheets.size)
Log.i("aaa", "rows " + rows)
for (int i = 0; i < sheets.length; i++) { //循环列出sheet
Sheet rs = rwb.getSheet(i);
for (int j = 0; j < rs.getRows(); j++) { //循环每一行的值
Cell[] cells = rs.getRow(j);
for(int k=0;k<cells.length;k++) //循环每一列的值
sb.append(cells[k].getContents());
}
}
}
})
thread.start()
}
网友评论