Click here to Skip to main content
15,896,278 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Here's what i'm trying to do:
- User clicks a button on the asp.net page (C#)
- Open an excel file
- Edit the content of the file
- Returning the excel file for user to download

I have found the way to open the excel file and edit the content (I'm replacing things like "[%customer_name%]" with some text that the user input before clicking the button). But i'm not sure how to have the excel file being returned into the context.Response, so that the user can be prompted to download the excel file.

How do i do that?

Many thanks in advance, and apologies if this has been asked before.. i just couldnt find it..
Posted

1 solution

To download a file in .net is not that hard

C#
//Set appropriate ContentType.
Response.ContentType = "Application/xls";

string fileh = MapPath("myFile.xls");

//Write the file to the output stream.
Response.WriteFile(file);
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900