从Excel文件获取和显示数据

我有一个超过80行的数据完整的Excel文件。 在特定的列中,我有我在代码中提到的数据。

我正在试图获取这些数据,然后在textView中显示它们。 不幸的是,当我运行我的应用程序,我得到以下显示:名称:jxl.read.biff.NumberRecord@ce3885a等。 你能帮我吗?

enter code here public void order(View v){try {AssetManager am = getAssets(); InputStream是= am.open(“data.xls”); 工作簿wb = Workbook.getWorkbook(is); 工作表s = wb.getSheet(0);

  EditText num=(EditText) findViewById(R.id.getID);//take input for id int row=Integer.parseInt(num.getText().toString()); //i have to get the patient ID from insert Cell name=s.getCell(row,6); Cell sex=s.getCell(row,7); Cell birthdate=s.getCell(row,8); Cell age=s.getCell(row,9); //display("Name: "+name+"/n"); //display("Sex: "+sex+"/n"); //display("Birth Date: "+birthdate+"/n"); //display("Age: "+age+"/n"); TextView textView=(TextView) findViewById(R.id.textView_data); textView.setTextSize(22); textView.setTypeface(null, Typeface.BOLD); //textView.setTextColor(000000); textView.setText("Name: "+name+"\n"+"Sex: "+sex+"\n"+"Birth Date: "+birthdate+"\n"+"Age: "+age); } catch(Exception e){ } } public void display(String value){ TextView x=(TextView) findViewById(R.id.textView_data); x.setText(value); } 

你看到的结果是单元格的内存地址。 那是因为你忘了获取单元格的内容,而你正在尝试读取单元格本身而不是内容。 你应该使用Cell.getContents(); 把一个单元格的内容读入一个String:

 Cell name = s.getCell(row,6); String nameString = name.getContents();