While dealing with excel I am getting following error:
Microsoft Excel cannot access the file 'C:\trng\abc.xslx'. 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.
I guess this is due to improper disposing of excel application.
Please tell me how to dispose an excel application properly
excelSheets = workbook.Worksheets; excelWorksheet = (Microsoft.Office.Interop.Excel.Worksheet)excelSheets.get_Item("sheet1"); int index = Convert.ToInt16(Session["id"]);
and one more thing i would like to tell that evrthng is fine when i am using VS 2010 inbuilt server.The problem pops up when i try to deploy the site over IIS 7.5.
Considering it that your issue doesn't belong to AccessDataBase,So I suggest you trying to ask question at MSDN's Office programming,and you can get more help there:
mannnn
Member
4 Points
11 Posts
Microsoft Excel cannot access the file
Apr 16, 2012 12:13 PM|LINK
Hi...
While dealing with excel I am getting following error:
Microsoft Excel cannot access the file 'C:\trng\abc.xslx'. 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.
I guess this is due to improper disposing of excel application.
Please tell me how to dispose an excel application properly
Thanks..
Yesteryear
Member
2 Points
1 Post
Re: Microsoft Excel cannot access the file
Apr 16, 2012 01:05 PM|LINK
Can this not be done from the Task Manager?
Regards
mannnn
Member
4 Points
11 Posts
Re: Microsoft Excel cannot access the file
Apr 17, 2012 09:23 AM|LINK
Hi
thanks for reply:)
I killed "EXCEL.EXE" from task manager as well as by using code.But problem still persists...
try
{
eapp = new Microsoft.Office.Interop.Excel.Application();
workbook = eapp.Workbooks.Open(datasource,
Type.Missing, Type.Missing, Type.Missing, Type.Missing,
Type.Missing, Type.Missing, Type.Missing, Type.Missing,
Type.Missing, Type.Missing, Type.Missing, Type.Missing,
Type.Missing, Type.Missing);
excelSheets = workbook.Worksheets;
excelWorksheet = (Microsoft.Office.Interop.Excel.Worksheet)excelSheets.get_Item("sheet1");
int index = Convert.ToInt16(Session["id"]);
..........................................
..........................................
}
catch (Exception ex)
{
ClientScript.RegisterStartupScript(this.GetType(), "script", "alert('" + ex.Message + "');", true);
}
finally
{
workbook = null;
excelWorksheet = null;
eapp.Quit();
eapp = null;
}
I have ensured that there is no "EXCEL.EXE" running before entering into try block but still it gives the same error..
mannnn
Member
4 Points
11 Posts
Re: Microsoft Excel cannot access the file
Apr 17, 2012 10:08 AM|LINK
and one more thing i would like to tell that evrthng is fine when i am using VS 2010 inbuilt server.The problem pops up when i try to deploy the site over IIS 7.5.
Decker Dong ...
All-Star
118619 Points
18779 Posts
Re: Microsoft Excel cannot access the file
Apr 18, 2012 01:36 AM|LINK
Hello mannn:)
Considering it that your issue doesn't belong to AccessDataBase,So I suggest you trying to ask question at MSDN's Office programming,and you can get more help there:
http://social.msdn.microsoft.com/Forums/en-us/exceldev/threads
mannnn
Member
4 Points
11 Posts
Re: Microsoft Excel cannot access the file
Apr 18, 2012 05:09 AM|LINK
hiii Decker Dong-MSFT
Thanks for your suggestion
Decker Dong ...
All-Star
118619 Points
18779 Posts
Re: Microsoft Excel cannot access the file
Apr 18, 2012 05:10 AM|LINK
No problem,my pleasure to correct you to a right place to ask……:-)