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).
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.
bobbybingali...
0 Points
2 Posts
open an excel file within web app
Nov 15, 2012 03:07 AM|LINK
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:
bbcompent1
All-Star
33849 Points
8767 Posts
Moderator
Re: open an excel file within web app
Nov 15, 2012 01:06 PM|LINK
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.
bobbybingali...
0 Points
2 Posts
Re: open an excel file within web app
Nov 15, 2012 10:12 PM|LINK
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!
bbcompent1
All-Star
33849 Points
8767 Posts
Moderator
Re: open an excel file within web app
Nov 16, 2012 10:04 AM|LINK
Well, if you have it on the web server path, you can use Server.MapPath method and that should get around this problem.