locked
How to get rid of this? RRS feed

  • Question

  • User-1798651445 posted

    Hi All,

       I have created a feature on web page to upload the file on server.

       The file should be .xls format.

       I have also provided the download button on the page. When download button is clicked , you will get the file to be uploaded.

       I save the file which I get after clicking Download button.

       Eventhougth the file extension is in ".xls". Internallay the file is in "html" format.

      How to ger rid of this. Because of this problem I am not able to connect to excel file.

    Regards

    Abdul 

    Sunday, December 2, 2007 7:39 AM

Answers

  • User372121194 posted

    Hi Adbul,

    Based on my understanding, you can upload the Excel file to the server, but the Excel file contains Html information when you download it from the server. If I have misunderstood you, please feel free to let me know.

    If we use Response objects to write the Excel file to the client, we can use the Response’s Close method to stop write the html information to client. For example:

            string strPath = Server.MapPath("~") + "/UploadControl/test.xls";
            FileInfo file = new FileInfo(strPath);
            Response.AddHeader("Content-Disposition", "attachment; filename=" + file.Name);
            Response.ContentType = "application/octet-stream";
            Response.WriteFile(file.FullName);
            Response.Flush();
            Response.Close();


    I hope this helps. 

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, December 4, 2007 3:56 AM

All replies

  • User1759999623 posted
    Can you provide your code for this?
    Sunday, December 2, 2007 9:14 AM
  • User372121194 posted

    Hi Adbul,

    Based on my understanding, you can upload the Excel file to the server, but the Excel file contains Html information when you download it from the server. If I have misunderstood you, please feel free to let me know.

    If we use Response objects to write the Excel file to the client, we can use the Response’s Close method to stop write the html information to client. For example:

            string strPath = Server.MapPath("~") + "/UploadControl/test.xls";
            FileInfo file = new FileInfo(strPath);
            Response.AddHeader("Content-Disposition", "attachment; filename=" + file.Name);
            Response.ContentType = "application/octet-stream";
            Response.WriteFile(file.FullName);
            Response.Flush();
            Response.Close();


    I hope this helps. 

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, December 4, 2007 3:56 AM