Click here to Skip to main content
15,868,019 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I want to download saved excel sheet from my application folder with adding it one extra column i.e, logged user's company id.

I have used below code for download excel sheet.

string filepath = Server.MapPath("~/Uploads/Sheet1.xlsx");

            FileInfo myfile = new FileInfo(filepath);


            if (myfile.Exists)
            {
                // Clear the content of the response
                Response.ClearContent();

                Response.AddHeader("Content-Disposition", "attachment; filename=" + myfile.Name);
                                Response.AddHeader("Content-Length", myfile.Length.ToString());

                Response.TransmitFile(myfile.FullName);


                Response.End();
Posted
Updated 5-May-15 2:27am
v2
Comments
Where is the issue?
dawood abbas 5-May-15 8:44am    
please read properly my post.
CHill60 5-May-15 8:54am    
Your post is incomplete. It doesn't show where you have attempted to add the extra column nor have you explained why it doesn't work. All your code does is download the spreadsheet - how do you open it?
When I added the comment there were no codes posted. Anyways, you edited and added. I will comment after some time.
You have not added any code to add new column.

1 solution

You have not added any code to add new column. Open the file first and then add new column to it.

Search for samples from Google. You will get it for sure.
 
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