Click here to Skip to main content
12,396,095 members (55,489 online)
Rate this:
 
Please Sign up or sign in to vote.
See more: VB 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 27-Oct-11 23:51pm
Updated 28-Oct-11 9: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
Top Experts
Last 24hrsThis month


Advertise | Privacy | Mobile
Web02 | 2.8.160721.1 | Last Updated 23 May 2013
Copyright © CodeProject, 1999-2016
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