2

I want to read a excel file from assets folder.once i read that file and i want to get all row and column in list view.String[] cell ={a1Val,b1Val,c1Val,d1Val};this is represents the values of three columns.Here I mentioned the code for while i am trying:

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();
        }
  }
Gopal Singh Sirvi
  • 4,539
  • 5
  • 33
  • 55
ram kumar
  • 187
  • 1
  • 1
  • 16

0 Answers0