我是新來的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);
}
}
});
}