我是新来的java,但一个快速学习者。 我试图让我的Android应用程序从EditText获取用户输入,在Excel列中搜索匹配的字符串,并返回另一列(同一行)的值。Java-错误与Eclipse阅读excel文件
我在构建路径上添加了一个jxl.jar,并且我的代码看起来应该可以工作。教我自己,我正在慢慢地搞清楚调试。这个问题似乎是源android.jar没有找到(如果我没记错的话)。我找到它,现在我得到“源附件不包含文件instrumentation.class源”
这是我第一个使用excel的应用程序。我需要以某种方式解决Android Manifest?
这里是我的代码,以防万一,任何帮助是非常赞赏!:
public class Frame_Bore extends Activity {
private String inputFile;
public void setInputFile(String inputFile) {
this.inputFile = "c:/Desktop/AAS Work/PDA Programs/JBDB.xls";
}
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.framebore);
Button Btn1 = (Button) findViewById(R.id.button1);
final EditText T1 = (EditText) findViewById(R.id.et1);
final EditText T2 = (EditText) findViewById(R.id.et2);
Btn1.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
// TODO Auto-generated method stub
String t1Value = T1.getText().toString();
File inputWorkbook = new File(inputFile);
Workbook w;
String bore = null;
try {
w = Workbook.getWorkbook(inputWorkbook);
Sheet sheet = w.getSheet("Frame-Bore");
int y = 6;
while (y < 200) {
int x = 2;
Cell columnB = sheet.getCell(x, y);
String motorframe = columnB.getContents();
if (motorframe == t1Value) {
Cell columnC = sheet.getCell(x + 1, y);
bore = columnC.getContents();
} else {
y = y + 1;
}
}
} catch (BiffException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
} finally {
T2.setText("" + bore);
}
}
});
}