我想从assets文件夹中读取一个excel文件。我读了那个文件,我想在列表视图中获取所有行和列。String[] cell ={a1Val,b1Val,c1Val,d1Val};
这表示三列的值。这里我提到了我正在尝试的代码:
HSSFSheet worksheet = myWorkBook.getSheet("Worksheet");
for (int i=0;i<= mySheet.getLastRowNum();i++)
{
if ((tempRow= mySheet.getRow(i)) != null)
{
HSSFRow row1 = worksheet.getRow(i);
//HSSFRow row1 = worksheet.getRow(0);
HSSFCell cellA1 = row1.getCell((short) 0);
String a1Val = cellA1.getStringCellValue();
HSSFCell cellB1 = row1.getCell((short) 1);
String b1Val = cellB1.getStringCellValue();
HSSFCell cellC1 = row1.getCell((short) 2);
int clval = (int) cellC1.getNumericCellValue();
String c1Val = Integer.toString(clval);
//c1Val = cellC1.getStringCellValue();
HSSFCell cellD1 = row1.getCell((short) 3);
String d1Val = cellD1.getStringCellValue();
String[] cell ={a1Val,b1Val,c1Val,d1Val};
ArrayAdapter<String> adapter = new ArrayAdapter<String>(this,
android.R.layout.simple_list_item_1, android.R.id.text1, cell);
listView.setAdapter(adapter);
adapter.notifyDataSetChanged();
}
}