Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

I am trying to do an Export to Excel using vb.net in a Windows Application, AND, I realize there are many good threads already here on the topic.

 

BUt I have a problem. I have added the Excel reference from COM, the Excel 11 Object Library, I can see it in my Solution Explorer, but I am still getting an error on my line:

 

Dim excelApp As New excel.application

 

with the wavy error line under excel.application

 

It's like it's not recognizing the reference. I have also tried an Imports and Inherits just for the heck of it, but still am not having any luck.

 

Help! I need to break through this first step.... :(

Posted

it's been a while, but we had to write something to export to excel. when I say we, I mean I had nothing to do with it, I tasked it out and let someone else handle it. ;-) but here's the important stuff in VB 2003

 

hope this helps as a starting point

 

Imports System.IO
Imports Microsoft.Office.Interop
Imports System.Runtime.InteropServices

...


   Dim oXl As New Excel.Application
   Dim oWb As Excel.Workbook
   Dim oWs As Excel.Worksheet
   
   Dim fl As FileInfo = New FileInfo(sbPath.ToString)
   If fl.Exists = True Then Kill(sbPath.ToString)
   
   oXl = New Excel.Application
   oWb = oXl.Workbooks.Add(sbPath.ToString)
   
   ...
   
   wkIndex = 1
   oWs = oWb.Worksheets(wkIndex) 'which worksheet in the workbook
   
   ...
   
   oWs.Cells(rowIndex, colIndex) = value
   
   
   ...
   
   oWb.SaveAs(sbPath.ToString)
   
   ...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

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...