Click here to Skip to main content
15,892,674 members
Please Sign up or sign in to vote.
4.00/5 (2 votes)
See more:
Hi,

I am trying to download excel using COM dll. I am able to generate excel using excel.Visible = true; excel.UserControl = true; within the development environment. But once I deployed into IIS I am unable to export excel at client machine.

Please help me in how can I do it?
Posted

Hi,

You can download any file using following command

C#
public void DownloadFile(string filePath)
        {
            if (File.Exists(Server.MapPath(filePath)))
            {
                string strFileName = Path.GetFileName(filePath).Replace(" ", "%20");
                Response.ContentType = "application/octet-stream";
                Response.AddHeader("Content-Disposition", "attachment; filename=" + strFileName);
                Response.Clear();
                Response.WriteFile(Server.MapPath(filePath));
                Response.End();
            }
        }
 
Share this answer
 
 
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