从 Excel 文件获取和显示数据

Getting and Display data from Excel file

我有一个 excel 文件,其中包含超过 80 行的数据。在特定的列中,我有我在代码中提到的数据。

我正在尝试获取这些数据,然后将它们显示在 textView 中。 Unfo运行ately 当我 运行 我的应用程序我得到以下 Display:Name: jxl.read.biff.NumberRecord@ce3885a 等等。你能帮我吗?

enter code herepublic无效订单(查看v){ 尝试{ 资产管理器 am=getAssets(); 输入流为=am.open("data.xls"); 工作簿 wb=Workbook.getWorkbook(is); Sheet 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(); 将单元格的内容读入字符串:

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