bhushan
bhushan

Reputation: 51

How to open Excel file in app instead of downloading in browser using C#?

This is my code to download Excel file.

HttpContext.Current.Response.Clear();
HttpContext.Current.Response.Buffer = true;
HttpContext.Current.Response.Charset = "";
HttpContext.Current.Response.ContentType = "application/ms-excel";
HttpContext.Current.Response.AppendHeader("content-disposition", "attachment ; filename=report.xlsx"); 

I want to open it in Excel.

Upvotes: 1

Views: 448

Answers (1)

Ralf Bönning
Ralf Bönning

Reputation: 15415

Have a look at Office Uri Schemas.

You can use in your html page a view command link like

<a href="ms-excel:ofv|u|http://contoso/Q4/budget.xls">Open in Excel</a>

These links work if office is installed on the computer (on mobile devices, too).

Upvotes: 1

Related Questions