엑셀파일을 만들고있는데... 파일이 만들어지질 않네요...

어디가 잘못됐는지 모르겠어요..폴더는 생성이 되는데 파일이 만들어지질않아요..


public class ExcelWriteTest extends Activity {


private Button btn_write_test;

private EditText edit_text;

private EditText edit_log;

private String mSdPath;

private String tag = "ExcelWriteTest";

@Override

protected void onCreate(Bundle savedInstanceState) {

// TODO Auto-generated method stub

super.onCreate(savedInstanceState);

setContentView(R.layout.excelwritetest);

btn_write_test = (Button)findViewById(R.id.btn_write_test);

edit_text      = (EditText)findViewById(R.id.edit_text);

edit_log       = (EditText)findViewById(R.id.edit_log);

String ext = Environment.getExternalStorageState();

if(ext.equals(Environment.MEDIA_MOUNTED)){

Log.i(tag, "----- onCreate - MOUNTED");

edit_text.setText("onCreate Mounted");

mSdPath = Environment.getExternalStorageDirectory().getAbsolutePath();

}else{

Log.i(tag, "----- onCreate - UN MOUNTED");

edit_text.setText("onCreate UNMounted");

mSdPath = Environment.MEDIA_UNMOUNTED;

}

}

public void mOnClick(View v){

StringBuilder sb = new StringBuilder();

if(v.getId() == R.id.btn_write_test){

try{

String rootdir  = Environment.getRootDirectory().getAbsolutePath();

String datadir  = Environment.getDataDirectory().getAbsolutePath();

String cachedir = Environment.getDownloadCacheDirectory().getAbsolutePath();

edit_text.setText(String.format("external state = %s\nRootDir=%s\nDataDir=%s\nCacheDir=%s", mSdPath, rootdir, datadir, cachedir));

// directory 생성

File dir = new File(mSdPath + "/excel_test");

dir.mkdir();

// 파일 생성

String szFileName = "output.csv";

File file = new File(mSdPath + "/excel_test/" + szFileName);

if (!file.exists()){

                mSdPath = "";

                }else{

               

                }

                WritableWorkbook workbook = null;

             WritableSheet sheet = null;


            

             try{

             

//FileOutputStream fos = new FileOutputStream(file);

FileOutputStream excelFile = openFileOutput(szFileName, Context.MODE_WORLD_WRITEABLE);

Log.i(tag, "success create file ");

sb.append("success create file");

        Label label = null;


        long start = 0;

        long end = 0;

             

       

        for(int i = 0 ; i < 5; i++){

                   workbook = Workbook.createWorkbook( excelFile);

                   workbook.createSheet("sheet1", 0);

                   sheet = workbook.getSheet(0);

                   Log.i(tag, "i : " + Integer.toString(i));

                   for( int j = 0; j < 10; j++){

                       label = new Label( j, 0, "test cell");

                       sheet.addCell( label);

                   }


                   workbook.write();

                   workbook.close();

       

}catch(FileNotFoundException e){

sb.append("========file not found err : " + e.toString());

Log.e(tag, "========file not found err : " + e.toString());

}catch(SecurityException e){

Log.e(tag, "========Security Exception err : " + e.toString());

sb.append("========Security Exception  err: " + e.toString());

}catch(Exception e){

Log.e(tag, "========Exception err : " + e.toString());

sb.append("======== Exception  err: " + e.toString());

}

}catch(Exception e){

Log.e(tag, "btn_write_test err : " + e.toString());

sb.append("btn_write_test err : " + e.toString() );

}

edit_log.setText(sb.toString());

}

}


}