Click here to Skip to main content
15,895,746 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Below is my code snippet:
VB
Dim ef2 As New Microsoft.Office.Interop.Excel.Application
Dim ws As New Microsoft.Office.Interop.Excel.Worksheet

'Imports all the tables from DataSet to new file.
For Each table In [dsExportToSAPData].Tables
    'Add new worksheet to the file.
    ws = ef2.Worksheets.Add(table.TableName)

    'Change the value of the first cell in the DataTable.;
    table.Rows(0)(0) = "This is new file!"

    'Insert the data from DataTable to the worksheet starting at cell "A1".
    ws.InsertDataTable(table, "A1", True)
Next

Problem here is am getting the Exception "Exception from HRESULT:0x800A03EC" when the below line executed...ws = ef2.Worksheets.Add(table.TableName)... Can anyone help how to solve this exception ?
Posted
Updated 28-Oct-11 9:23am
v2

Does excel starts from index 0?
For example, here:
http://www.techonthenet.com/excel/formulas/row.php[^] it seems that indexing starts from 1.
Try changing
table.Rows(0)(0) = "This is new file!"


to
table.Rows(1)(1) = "This is new file!"
 
Share this answer
 
 
Share this answer
 
tari maa no bhosdo......bhenchhod.....chhodu jeva page na banavishh
 
Share this answer
 

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