我正在嘗試使用eclipse工作區閱讀安卓應用程序的Excel表格。我把文件路徑,但它似乎甚至沒有找到它。我需要在某處聲明文件的路徑嗎?閱讀安卓程序的Excel表格
以下是我的代碼。感謝您的幫助!
public void onCreate(Bundle savedInstanceState) {
vibrator = (Vibrator) getSystemService(Context.VIBRATOR_SERVICE); // calls VIBRATOR_SERVICE when button is pressed
screensize = getScreenSize();
setTheme(android.R.style.Theme_Translucent_NoTitleBar);
super.onCreate(savedInstanceState);
Eula.show(this); // displays the EULA and asks user to Accept or Don't Accept
try{
fs = new FileInputStream(new File("/Users/paul/Desktop/CollegeTrack/Samp.xls"));
InputStream fileinput = fs;
try{
Workbook workbook = Workbook.getWorkbook(fileinput);
sheet = workbook.getSheet(0);
database_array = Database.classDatabase(sheet); //stores each row in an array
workbook.close();
}
catch (BiffException e) {
e.printStackTrace();
}
catch (IOException e) {
e.printStackTrace();
}
fs.close();
}
catch (IOException e) {
e.printStackTrace();
}
savedAssignments_array = Database.assignmentDatabase();
savedCourses_array = Database.savedCourses();
goToWelcomeScreen();
}
你有什麼例外。這個看起來很正確。你可能會得到一個IOException。你讀過異常堆棧跟蹤嗎? – 2011-04-19 16:27:14