reading excel colums in vb.net + more

Levu

Well-known member
Joined
Jun 13, 2007
Messages
51
Location
Norway - Drammen
Programming Experience
1-3
Hello.

Well, looks like im not off the hook with vb.net + excel yet. :(
And the more I work with it, the more confusing it gets.. Atleast I feel that way..

Well, my problem now:
Im going to import 1x Excel worksheet..
Then its going to create 2x new colums at the left side. Like trow all in colum A, and B one to the right, so I get space..
Then im going to make a header for those two, like Status, and Names.
Then depending on whats in column C (new C, former A), im going to give column A ( the new one) some text, and the same with the new column B, but that one is going to change data based on another column (Column H).

And then, the last part.. At the end, its going to do some checks.. Depending on whats in the new column A, the color of the column is going to change. Like red if the status is Offline or whatever.

Is this possible in VB.net? Or do I have to make it in VB 6? (Or in Excel as a macro).
Would realy like to get it in my program that iv already started at..



EDIT:
Just found another way to do it..
I'll just read line by line from the excel worksheet, and place it in a database..
Then export the information i want to a new excel file..
But then again, I need some help :p
First of all, iv only managed to read lines, and the first column..


My code:

VB.NET:
        Try
            myconnection = New System.Data.OleDb.OleDbConnection("provider=Microsoft.jet.oledb.4.0; Data source='" & path1 & "'; extended properties=Excel 8.0")
            input = InputBox("Sett inn navn på arbeidsark")
            If Not input = "" Then
                mycommand = New System.Data.OleDb.OleDbDataAdapter("Select * From [" & input & "$]", myconnection)
                dtset = New System.Data.DataSet
                mycommand.Fill(dtset)
            End If

            DataGridView1.DataSource = dtset.Tables(1)
        Catch ex As Exception
            MsgBox(ex.Message)
        End Try

        myconnection.Close()

But then AGAIN! Won't this require that all the comps got Access? If I do it like this..
This is supposed to be running at different comps at my office, and currently, noone got access as far as I can tell..

What a hassle :(


OR ! the third option, XML.. But then again, I still need help on how to read columns and rows at the same time, or the column at the specific row.. + Writing XML files..
Currently googling after it, but not so much luck yet.. Even tho i bet there is alot about it out there...
 
Last edited:

Latest posts

Back
Top