Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1350
  • Last Modified:

Error Parsing Excel on IIS7 on Server 2008

We have an application (C#) that :
1. uploads excel files to the server
2. extracts data from excel file
3. writes data to SQL Server 2005

Everything works locally. The problem arises when app runs on server. Here is the error

System.Runtime.InteropServices.COMException (0x800A03EC): Microsoft Office Excel cannot access the file 'D:\RNGWeb\5-Virtual\templates\SSS\temp\37\Arcandor AG.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.
   at Microsoft.Office.Interop.Excel.Workbooks.Open(String Filename, Object UpdateLinks, Object ReadOnly, Object Format, Object Password, Object WriteResPassword, Object IgnoreReadOnlyRecommended, Object Origin, Object Delimiter, Object Editable, Object Notify, Object Converter, Object AddToMru, Object Local, Object CorruptLoad)
   at RNG.ADU.SSSProcesser.ExtractAndExport() in C:\Trunk\RNG.ADU\Processer\SSSProcesser.cs:line 52 (D:\RNGWeb\5-Virtual\templates\SSS\temp\37\Arcandor AG.xlsx)

It's happening while trying to open a workbook

Here is the code:

protected override void ExtractAndExport()
        {


            Application excelApp = null;
            Workbook workbook = null;

            try
            {
                // instantiate excel application
                excelApp = new Application();
            }
            catch (Exception ex)
            {
                m_logger.Error(String.Format("{0} ({1})", ex.ToString(), TemplatePath));
                return;
            }

            try
            {
                // find excel file
                workbook = excelApp.Workbooks.Open(
                    TemplatePath,   // Filename
                    0,              // UpdateLinks
                    true,           // ReadOnly
                    5,              // Format
                    "",             // Password
                    "",             // WriteResPassword
                    false,          // IgnoreReadOnlyRecommended
                    XlPlatform.xlWindows, // Origin
                    "",             // Delimiter
                    false,          // Editable
                    false,          // Notify
                    0,              // Converter
                    true,           // AdToMru
                    false,          // Local
                    false           // CorruptLoad
                    );
            }
            catch (Exception ex)
            {
                m_logger.Error(String.Format("{0} ({1})", ex.ToString(), TemplatePath));
                return;
            }

          ...
        }

I've given NETWORK Service, IUSR, and ASPNET full access to files location. I also added these accounts to DCOM for Microsoft Excel Application.

------------------------------------------------------

Server Environment

Windows Server 2008
.NET Framework 2.0 (version 2.0.50727.42)
MIcrosoft Office 2007
SQL Server 2005

Local Environment

XP
ASP.NET (VS2005)
MIcrosoft Office 2007
SQL Server 2005

------------------------------------------------------

Please let me know if you need more info to understand the issue.

Thanks in advance
0
RNGAdmin
Asked:
RNGAdmin
1 Solution
 
cj_1969Commented:
Chances are the Network service account that is typically used to run applications through IIS does not have the permissions it needs to do this.

Try changing the account that the application pool is using to local service account and see if this resolves the problem.
0
 
RNGAdminAuthor Commented:
Where can I do that?
0

Featured Post

Transaction-level recovery for Oracle database

Veeam Explore for Oracle delivers low RTOs and RPOs with agentless transaction log backup and transaction-level recovery of Oracle databases. You can restore the database to a precise point in time, even to a specific transaction.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now