Click here to Skip to main content
15,887,875 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello All,
I came across this problem.
I am reading Text Data from Excel sheet.
I use the lines

while (((Microsoft.Office.Interop.Excel.Range)workSheet.Cells[rowIndex, colIndex1]).Value2 != null)//OK until here.:thumbsup:
{
string firstName = ((Microsoft.Office.Interop.Excel.Range)workSheet.Cells[rowIndex, colIndex1]).Value2.ToString();// exception is here.:confused:

//some more code goes here.
}

but this gives me an exception "Exception from HRESULT: 0x800A03EC".

NOTE: i am using C# and i have added micorsoft object library 11 and excel object library 11


Please help me how this problem can be solved.
I went through google where there was information about some regionaloptions but i dont think that should be a problem in my case as i am just reading text.
Posted
Comments
Rob Branaghan 29-Jun-10 4:27am    
Just a wild shot in the Dark, can you use Try Catch in Excel in C#?

string firstName = "";
try
{
firstName = ((Microsoft.Office.Interop.Excel.Range)workSheet.Cells[rowIndex, colIndex1]).Value2.ToString();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message.ToString();
}

I havent really tried much in excel, but at least you should get the reason why your getting the error from that catch if it works?
asjadazeez 29-Jun-10 4:54am    
i have used the try catch stuff. thats where i get the exception and Exception from HRESULT: 0x800A03EC.

1 solution

http://social.msdn.microsoft.com/Forums/en-US/vsto/thread/412dd4d6-df62-449c-bb3b-f53cb408ab68
Have a look there but also at the link below.

It could be a security issue as described in link below.

http://support.microsoft.com/kb/282830/
 
Share this answer
 
Comments
asjadazeez 29-Jun-10 5:23am    
Well this is not what i am exactly looking at.
Rob Branaghan 29-Jun-10 5:58am    
http://p2p.wrox.com/book-beginning-visual-c/38178-check-if-cell-blank-excel.html

Scroll down that page, they said to test if the value2 is null rather than to string first?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900