locked
open an excel file within web app RRS feed

  • Question

  • User-1646529238 posted

    Hi,

    Losing some sleep on this.

    i have an excel template which i copy then try to open (thsi is all within a dll within my website).

    the file copies and exists (with a system.io.file.exists)

    however when i attempt the file open with excel it fails

    command i'm using is:

     xlsWorkBook = XLS.Workbooks.Open(strFilename, , False)
    
    the error is:

    Microsoft Office Excel cannot access the file 'abcd.xlsm'.
    There are several possible reasons: 
    The file name or path does not exist.
    The file is being used by another program.
    he workbook you are trying to save has the same name as a currently open workbook.

    I'm confused as firstly the code works locally no problems and secondly the file exists.

    so i'm not sure if its becaue the file is located outside of the website space (in some other folder).

    any help appreciated.
    Wednesday, November 14, 2012 11:07 PM

Answers

  • User-718146471 posted

    Well, if you have it on the web server path, you can use Server.MapPath method and that should get around this problem.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, November 16, 2012 6:04 AM

All replies

  • User-718146471 posted

    Best practices dictate that this file should exist inside the web folder otherwise you will have to do hard coded paths which can cause problems if you move the site. I'd suggest putting the file in a folder under the web site.

    Thursday, November 15, 2012 9:06 AM
  • User-1646529238 posted

    yes i thought the same - the file is within the web app directory but i'm accessing via disk paths

    ie c:\aaa\bbb\ccc\file.xlsm

    is this likely to caues a problem?

    or how would i path an open file from within a dll to a web directory?

    thanks!

    Thursday, November 15, 2012 6:12 PM
  • User-718146471 posted

    Well, if you have it on the web server path, you can use Server.MapPath method and that should get around this problem.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, November 16, 2012 6:04 AM