Excel 파일을 읽으려고합니다. 파일은 내 작업 공간의 RoCom_DB
폴더에 보관되며 파일 이름은 RoCom.xlsx
입니다. android에서 Excel 파일을 읽는 중 문제가 발생했습니다.
public String readComplexExcelFile(Context context){
try{
// Creating Input Stream
File file = new File(Environment.getExternalStorageDirectory()
+ "/Android/data/" + getApplicationContext().getPackageName()
+ "/RoCom_DB/", "RoCom.xlsx");
FileInputStream myInput = new FileInputStream(file);
// Create a POIFSFileSystem object
POIFSFileSystem myFileSystem = new POIFSFileSystem(myInput);
// Create a workbook using the File System
HSSFWorkbook myWorkBook = new HSSFWorkbook(myFileSystem);
// Get the first sheet from workbook
HSSFSheet mySheet = myWorkBook.getSheetAt(0);
/** We now need something to iterate through the cells.**/
Iterator<Row> rowIter = mySheet.rowIterator();
while(rowIter.hasNext()){
HSSFRow myRow = (HSSFRow) rowIter.next();
Iterator<Cell> cellIter = myRow.cellIterator();
while(cellIter.hasNext()){
HSSFCell myCell = (HSSFCell) cellIter.next();
Log.d("", "Cell Value: " + myCell.toString());
Toast.makeText(context, "cell Value: " + myCell.toString(), Toast.LENGTH_SHORT).show();
}
}
}catch (Exception e){
e.printStackTrace();
}
return "";
}
문제는 내가 파일을 읽을하려고 할 때마다, 나는이 File not found exception
를 얻을. 나는이 하나 poi-3.7.jar
필요한 사용하고 코드의 조각을 유지 한 내 manifest.xml
: 그것은 단지 지원하는 1메가바이트 개까지 엑셀 내 파일이 나는이 assets
디렉토리에서 엑셀을 사용하지 않으
<uses-permission
android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
크기가 커질 가능성이있다.
아무도 내가 뭘 잘못하고 있다고 말할 수 있습니까? 어떤 도움이라도 대단히 감사합니다. 감사 .
감사합니다. 나는 그것을 시도하고 다시 연락 할 것입니다. –