RNGAdmin
asked on
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.InteropServ ices.COMEx ception (0x800A03EC): Microsoft Office Excel cannot access the file 'D:\RNGWeb\5-Virtual\templ ates\SSS\t emp\37\Arc andor 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.E xcel.Workb ooks.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.Extra ctAndExpor t() in C:\Trunk\RNG.ADU\Processer \SSSProces ser.cs:lin e 52 (D:\RNGWeb\5-Virtual\templ ates\SSS\t emp\37\Arc andor 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.Form at("{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.Form at("{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
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.InteropServ
" 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.E
at RNG.ADU.SSSProcesser.Extra
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.Form
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.Form
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
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER