Nimeton
Nimeton

Reputation: 109

Which MIME data type for Android Excel CSV?

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);
}

Upvotes: 5

Views: 5979

Answers (3)

codegames
codegames

Reputation: 1921

For me, these mime types worked:

  • XLS => application/vnd.ms-excel

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

  • CSV => text/comma-separated-values

Upvotes: 10

chornge
chornge

Reputation: 2111

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

Upvotes: 3

Husayn Hakeem
Husayn Hakeem

Reputation: 4570

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

Upvotes: 5

Related Questions