Login    
 
 
 
 
Text/HTML
  
You are here :: Blogs Saturday, May 19, 2012

Search
Note: This uses the internal blog search engine. The Google search engine is also available at the top of the page.
  
Disclaimer

Please review the site disclaimer before downloading or using content found on this site

  
Categories
  
DEVSHED Blog
As always, I welcome your comments!
Sep 14

Written by: Steve Gray
9/14/2010 1:53 PM  RssIcon

I’m trying to get data imported into VB from Excel, and I’m going round in circles. I tried exporting Excel to comma-separated, but embedded commas gave me fits. Then I tried using a tab-delimited export. Better, but line feed characters are causing trouble.

Today I’m trying to read form Excel directly, using Microsoft.Office.Interop,Excel.dll (deep breath)

Dim oExcel As New Microsoft.Office.Interop.Excel.Application
Dim oBook As Microsoft.Office.Interop.Excel._Workbook = 
oExcel.Workbooks.Open("N:\Sedgwick\100914_SedgwickTest_4_Upload.xlsx") Dim oSheet As _Worksheet = oBook.Worksheets(1) 'Read value in A2 cell Dim cellValue As String = oSheet.Range("A2").Value 'get values from the first row Dim cellValue2 As System.Object(,) = oSheet.Range("A2:h2").Value 'Change value in A2 cell oSheet.Range("A2").Value = "" 'get the number of rows Dim intRows As Int16 = oSheet.Rows.CurrentRegion.Rows.Count 'Save this Excel document oBook.SaveAs("C:\Book1.xls", True) oExcel.Quit()

Tags:
Categories:
As always, I welcome your comments!
  
 
 
Home | Products | Blogs | Contact Us | Links | God's Plan
Privacy Statement | Terms Of Use
 
Copyright 2011 by Devshed.us