Groups | Blog | Home
all groups > dotnet faqs > august 2004 >

dotnet faqs : Excel File Format of ".CVS"


a NO[at]SPAM b.c
8/17/2004 11:57:51 AM
Dear Programmers,

Could anyone send me to the right location to find code/example on how to
take information from Excel File Format of ".CVS" into VB.Net for data
manipulation?

TIA

Kkaptain


_thedebugger
8/18/2004 11:26:58 AM
Hi Tia,
I hope you are talking about .CSV and not .CVS.
(CSV is Comma Seperated Values), which is basically text file.

I worked on this earlier, where I have found this...may be usefull to you.

Here is a solution suggested by Elan Zhou (MS) on the
microsoft.public.dotnet.languages.vb newsgroup.

You can also use the following code:
1. Put a DataGrid on the form.
2. Try the following sample code: (Suppose the csv is c:\test.csv.)



Imports System.Data

Imports System.Data.OleDb





Public Class Form1

Inherits System.Windows.Forms.Form

Dim objDataset1 As DataSet()



Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load



Dim sConnectionString As String =
"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=c:\;Extended Properties=Text;"

Dim objConn As New OleDbConnection(sConnectionString)

objConn.Open()



Dim objCmdSelect As New OleDbCommand("SELECT * FROM
test.csv", objConn)

Dim objAdapter1 As New OleDbDataAdapter()

objAdapter1.SelectCommand = objCmdSelect



Dim objDataset1 As New DataSet()

objAdapter1.Fill(objDataset1, "Test")

DataGrid1.DataSource = objDataset1.Tables(0).DefaultView

objConn.Close()

End Sub

End Class







[quoted text, click to view]

AddThis Social Bookmark Button