如何在列表视图中添加excel的列和行值?

时间:2015-06-29 12:59:13

标签: android android-listview

我想从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();
        }
  }

0 个答案:

没有答案