2

I am exporting a excel file from "c:Test\data.xls" using the responce object like:

response.AddHeader("Content-Disposition", "attachment; filename=" + FileName + ";");

it is opening a dialog box.But Now we don't need the dialog box.we want to directly open file without dialog. Can any body help me out

2 Answers 2

1

use

response.AddHeader("Content-Disposition", "inline; filename=" + FileName + ";");

Whether it opens directly depends on client-side security settings to this might work but there is no guarantee...

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

Comments

0

Instead of attaching file to response you nee write it's content to response stream.

//Set the appropriate ContentType.
Response.ContentType = "application/vnd.ms-excel"; // not sure in content type
//Get the physical path to the file.
string filePath = @"c:Test\data.xls";
//Write the file directly to the HTTP content output stream.
Response.WriteFile(filePath);
Response.End();

But also it depeneds on the client side settings.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.