Click here to Skip to main content
11,495,688 members (69,592 online)
Rate this: bad
good
Please Sign up or sign in to vote.
See more: VB.NET
Below is my code snippet:
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 28-Oct-11 0:51am
Edited 28-Oct-11 10:23am
v2
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

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!"
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 3

tari maa no bhosdo......bhenchhod.....chhodu jeva page na banavishh
  Permalink  

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

  Print Answers RSS
0 Dnyaneshwar@Pune 692
1 CHill60 318
2 Sascha Lefèvre 275
3 Nakul Chaudhari 236
4 RyanDev 220
0 Sergey Alexandrovich Kryukov 10,362
1 OriginalGriff 8,821
2 Sascha Lefèvre 3,899
3 Maciej Los 3,422
4 Richard Deeming 2,600


Advertise | Privacy | Mobile
Web04 | 2.8.150520.1 | Last Updated 23 May 2013
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100