Reputation: 109
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
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
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