Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

Hello folks,

 

I have used excel from vb.net loads of times and normally manage it with no problems. This time, I have one event opening the spreadsheet and associating it with an object, and then another event which writes to the spreadsheet. Everything seems fine apart from when it is run and the line which the error occurs in should simply write to a cell. I get the message HRESULT: 0x800A03EC. The objects are defined in the main body of the code as public and each of the events metioned earlier refer to these. Anyone had this problem before? Im sure its probably just me being stupid as usual but I cant see where im going wrong.

 

Cheers for any ideas.

 

Chris

Chris
Posted

I have had the same error, and searched for it for about an hour, eventually I found the solution.

I had written a loop to write different values into different cells. It went something like this:

 

for i = 0 to 10

sheet.cells("A" & i) = "test"

next

 

Actually it's quite obvious, but there is no cell "A0" :-)

You should start counting from one...

  • 1 month later...
Posted

I got the following error :

Exception from HRESULT: 0x800A03EC.

 

Which is the same.

 

I'm doing it on ASP.NET with C#. I want the server-side to interpret Data from a excel file.

 

Here is my code :

 

[size=2][color=#0000ff]private[/color][/size][size=2][color=#0000ff]void[/color][/size][size=2] Button1_Click([/size][size=2][color=#0000ff]object[/color][/size][size=2] sender, System.EventArgs e)[/size]
[size=2]{[/size]
[size=2]     Workbooks oWbs = [/size][size=2][color=#0000ff]null[/color][/size][size=2];[/size]
[size=2]     Workbook oWb = [/size][size=2][color=#0000ff]null[/color][/size][size=2];[/size]
[size=2][color=#0000ff]     try[/color][/size]
[size=2]     { [/size]
[size=2]          oWbs = oExcel.Workbooks;[/size]
[size=2]          oWb = oWbs._Open(@"C:\Inetpub\wwwroot\Location\tests.xls",[/size][size=2][color=#0000ff]null[/color][/size][size=2],[/size][size=2][color=#0000ff]null[/color][/size][size=2],[/size][size=2][color=#0000ff]null[/color][/size][size=2],[/size][size=2][color=#0000ff]null[/color][/size][size=2],[/size][size=2][color=#0000ff]null[/color][/size][size=2],[/size][size=2][color=#0000ff]null[/color][/size][size=2],[/size][size=2][color=#0000ff]null[/color][/size][size=2],[/size][size=2][color=#0000ff]null[/color][/size][size=2],[/size][size=2][color=#0000ff]null[/color][/size][size=2],[/size][size=2][color=#0000ff]null[/color][/size][size=2],[/size][size=2][color=#0000ff]null[/color][/size][size=2], [/size][size=2][color=#0000ff]null[/color][/size][size=2]);[/size]
[size=2]          Response.Write("It works");[/size]
[size=2]          Response.Write("<br>");[/size]
[size=2]     }[/size]
[size=2][color=#0000ff]     catch[/color][/size][size=2](Exception ex)[/size]
[size=2]     {[/size]
[size=2]          NAR( oWbs );[/size]
[size=2]          NAR( oWb );[/size]
[size=2]          oExcel.Quit();[/size]
[size=2]          NAR(oExcel);[/size]
[size=2]          Response.Write( ex.Message );[/size]
[size=2]     }[/size]
[size=2]}[/size]

 

Thanks

"If someone say : "Die mortal !"... don't stay to see if he isn't." - Unknown

"Learning to program is like going out with a new girl friend. There's always something that wasn't mentioned in the documentation..." - Me

"A drunk girl is like an animal... it scream at everything like a cat and roll in the grass like a dog." - Me after seeing my girlfriend drunk and some of her drunk friend.

C# TO VB TRANSLATOR

Posted

That's it. I solved the problem... I think :D

 

I changed Open(filename) by Add(filename) and it work. At least it return a value.

 

Oh... yes I set the right permission to ASPNET account (fullcontrol). I think it's maybe an old command for older Excel or something or I dunno.

 

I have another problem with getting the right range.

I want to have all columns header (A1:A??).

But it said invalid type :

 

Range rng = ws.Columns.get_range( ws.Columns.Cells["A", "1"], ws.Columns.Cells["A", ws.Columns.Count.ToString()];

"If someone say : "Die mortal !"... don't stay to see if he isn't." - Unknown

"Learning to program is like going out with a new girl friend. There's always something that wasn't mentioned in the documentation..." - Me

"A drunk girl is like an animal... it scream at everything like a cat and roll in the grass like a dog." - Me after seeing my girlfriend drunk and some of her drunk friend.

C# TO VB TRANSLATOR

Posted
Because in the first parameter I putted a string so I tought that I shall be constant.

"If someone say : "Die mortal !"... don't stay to see if he isn't." - Unknown

"Learning to program is like going out with a new girl friend. There's always something that wasn't mentioned in the documentation..." - Me

"A drunk girl is like an animal... it scream at everything like a cat and roll in the grass like a dog." - Me after seeing my girlfriend drunk and some of her drunk friend.

C# TO VB TRANSLATOR

Posted

However ... here is my exact code :

[size=2][color=#0000ff]public[/color][/size][size=2][color=#0000ff]string[/color][/size][size=2] [] GetColumnsHeaders()

{

Range rng = [/size][size=2][color=#0000ff]null[/color][/size][size=2];

[/size][size=2][color=#0000ff]try

[/color][/size][size=2]{

rng = m_ws.Columns.get_Range( m_ws.Columns.Cells["A",1], m_ws.Columns.Cells["A", m_ws.Columns.Count]);

[/size][size=2][color=#0000ff]string[/color][/size][size=2] [] test = [/size][size=2][color=#0000ff]new[/color][/size][size=2][color=#0000ff]string[/color][/size][size=2][rng.Count];

NAR( rng);

[/size][size=2][color=#0000ff]return[/color][/size][size=2] test;

}

[/size][size=2][color=#0000ff]catch

[/color][/size][size=2]{

NAR( rng );

Dispose();

[/size][size=2][color=#0000ff]return[/color][/size][size=2][color=#0000ff]null[/color][/size][size=2];

}

}

[/size]

 

[edit2]The NAR function is the one that were so much talked about but translated to C#.[/edit2]

"If someone say : "Die mortal !"... don't stay to see if he isn't." - Unknown

"Learning to program is like going out with a new girl friend. There's always something that wasn't mentioned in the documentation..." - Me

"A drunk girl is like an animal... it scream at everything like a cat and roll in the grass like a dog." - Me after seeing my girlfriend drunk and some of her drunk friend.

C# TO VB TRANSLATOR

Posted

Stop everything there.

I'm stupid and I admit it.

 

m_ws.Cells[1,1] work better than m_ws.Cells["A", 1].

 

You can throw me rocks if you want.

It seems to calm stupidy in my damn head also.

 

Thanks anyway dude !

"If someone say : "Die mortal !"... don't stay to see if he isn't." - Unknown

"Learning to program is like going out with a new girl friend. There's always something that wasn't mentioned in the documentation..." - Me

"A drunk girl is like an animal... it scream at everything like a cat and roll in the grass like a dog." - Me after seeing my girlfriend drunk and some of her drunk friend.

C# TO VB TRANSLATOR

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...