Viewing excel files in my android app

后端 未结 1 822
醉酒成梦
醉酒成梦 2020-12-05 15:56

I\'m working on an Android app in which I have to open & close excel files on button click. These excel files will be readonly. After closing the excel file, it should d

相关标签:
1条回答
  • 2020-12-05 16:19

    Android 7.0 Update:

    Android 7.0 will throw FileUriExposedException if you try to open your app document with an external app. You need to implement FileProvider refer This Answer.


    here is a manual route.

    Using JExcelApi in an Android App

    How to read excel file using JXL 2.6.12 jar


    but here is a little more easier one.

    open application

    but i guess you have to find out the MIME TYPE.

    EDIT

    got the mime type as well

    Setting mime type for excel document

    UPDATE

    so something like this might work.

    Intent intent = new Intent(Intent.ACTION_VIEW);
    intent.setDataAndType(path, "application/vnd.ms-excel");
    intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
    
    
    try {
        startActivity(intent);
    } 
    catch (ActivityNotFoundException e) {
        Toast.makeText(OpenDoc.this, "No Application Available to View Excel", Toast.LENGTH_SHORT).show();
    }
    
    0 讨论(0)
提交回复
热议问题