Android中的JXL库
目前我正在尝试在Android中使用Jxl lib从SD卡读取数据并获取FilenotfoudException。
我用stackoverflowsearch解决scheme,并find一些。 但他们似乎没有为我工作。 我有以下代码实现:/ 代码部分 /
File sdcard = Environment.getExternalStorageDirectory(); //Get the text file File Excelfile = new File(sdcard,"ExcelTest.xls"); // try { Workbook wrkbk = Workbook.getWorkbook(Excelfile); Sheet sheet1 = wrkbk.getSheet(0); //Obtain reference to the Cell using getCell(int col, int row) method of sheet Cell colArow1 = sheet1.getCell(0, 0); Cell colBrow1 = sheet1.getCell(1, 0); Cell colArow2 = sheet1.getCell(0, 1); //Read the contents of the Cell using getContents() method, which will return //it as a String String str_colArow1 = colArow1.getContents(); String str_colBrow1 = colBrow1.getContents(); String str_colArow2 = colArow2.getContents(); } Catch(Exception ex){}
我总是在行Workbook wrkbk = Workbook.getWorkbook(Excelfile);
我已经寻找解决scheme,但似乎没有任何工作。 我已经提供了读取SD卡上的文件的所有权限(通过阅读文本文件检查,它工作正常)。
相同的代码在普通的java程序中工作。
请帮忙…..
这可能是迟到的答案,但您的实际文件可能在文件夹中的某个地方。 因此,你必须得到完整的path。 就你而言,它是
File sdcard = Environment.getExternalStorageDirectory(); File Excelfile = new File(sdcard,"/folder_name/ExcelTest.xls");
希望这会有所帮助。