How to open an excel file in android

前端 未结 5 873
广开言路
广开言路 2021-01-06 08:25

I have downloaded the excel file to sdcard. want to open the file in my app and process it. Is there any way or any intent to open an excel file in android. I

5条回答
  •  鱼传尺愫
    2021-01-06 08:41

    Uri path = Uri.fromFile(file);
    Intent excelIntent = new Intent(Intent.ACTION_VIEW);
    excelIntent.setDataAndType(path , "application/vnd.ms-excel");
    excelIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
    try {
        startActivity(excelIntent);
    } catch (ActivityNotFoundException e) {
        Toast.makeText(EmptyBlindDocumentShow.this,"No Application available to viewExcel", Toast.LENGTH_SHORT).show();
    }
    

提交回复
热议问题