2014-04-25 114 views
2

我創建了每行讀取excel文件的Web應用程序,當我從本地主機運行它時,它完美地工作。 但是,當我將其部署到網絡服務器[贏得7 64比特],它產生誤差這樣的:Microsoft Excel無法訪問ASP.net項目中的文件

Microsoft Excel cannot access the file 'C:\TestReadExcel\testdata.xlsx'. There are several possible reasons: 

• The file name or path does not exist. 
• The file is being used by another program. 
• The workbook you are trying to save has the same name as a currently open workbook. 

從該代碼來此錯誤(我用的Microsoft.Office.Interop.Excel):

Line 195:  Dim workbook = xlApplication.Workbooks.Open(fileName) 
.. 
.. 

我已經嘗試了各種辦法:

1. add folder **desktop** C:\Windows\System32\config\systemprofile\ and in C:\Windows\SysWOW64\config\systemprofile -it not working 
2. add security account for network services and iis_iusrs in DCOM config - microsoft excel application (allow all) - it not working 
3. already restart my web server after i configured step 1-2 , and still not working 
4. already test to add security account full control in folder C:\TestReadExcel\ , and still not working 

還有什麼,我需要做的來解決這個問題? 還是有什麼比使用interop excel的方式嗎?

需要你的幫助謝謝。

+0

Is is the IIS machine is a local machine than localhost?如果是這樣,web服務器上實際上是否存在「C:\ TestReadExcel \ testdata.xlsx」路徑? – squillman

+0

IIS機器與我的本地主機相同,並且該文件夾存在 –

+0

並且應用程序池在您在第4點中提到的安全帳戶的上下文中運行? – squillman

回答

0

使用Server.Mappath來獲取文件路徑。並確保IIS_User具有讀取放置Excel文件的文件夾的權限。

相關問題