5

I tried "text/csv" and even "application/vnd.ms-excel", but Excel won't show in the list of choices. Plenty of other apps do.

void shareCsv(Uri uri, Context context) { Intent intent = new Intent(); intent.setAction(Intent.ACTION_SEND); intent.setType("text/csv"); intent.putExtra(Intent.EXTRA_STREAM, uri); intent.setFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); context.startActivity(intent); } 

3 Answers 3

11

For me, these mime types worked:

  • XLS => application/vnd.ms-excel

  • XLSX => application/vnd.openxmlformats-officedocument.spreadsheetml.sheet

  • CSV => text/comma-separated-values

Sign up to request clarification or add additional context in comments.

Comments

5

It should be application/vnd.ms-excel (source)

Comments

3

You can try:

void shareCsv(Uri uri, Context context) { Intent intent = new Intent(); intent.setAction(Intent.ACTION_SEND); intent.setType("application/excel") //replace "text/csv" with application/excel intent.putExtra(Intent.EXTRA_STREAM, uri); intent.setFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); context.startActivity(intent); } 

Here's a link to the .xls mime-types you can use. If one type isn't working for you, try another.

List of choices for Excel:

  • application/excel
  • application/vnd.ms-excel
  • application/x-excel
  • application/x-msexcel

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.