Processing Excel cell values in VB.Net (Please help, its urgent)

Dear Experts,

I need to process attached excel and insert these records into oracle table. I have below code works for me. Moreover excel's cell(A1) is not readable. Using below code I am reading 1st 3 cells:

                Dim cmdExcel = New OleDbCommand("select * from [" & strWSheetName & "$]", connExcel)
                daExcel.SelectCommand = cmdExcel
                daExcel.Fill(ds, "CUSTOMER")
                dTable1 = ds.Tables(0)

                           strCUST_NAME = dTable1.Rows(0).Item(0).ToString()
                     strS_E_DATE   = dTable1.Rows(1).Item(0).ToString()
                     strDISC_DATE  = dTable1.Rows(2).Item(0).ToString()

Its skipping the R1 row and starting from R2. If I move R1-R3 to R2-R4 then it works fine and I get expected output. Moreover I need expected output without any modification.

Source Records format: Refer Attachment
R1 Customer: SYNTEL                  
R2 Period: 2016-12 - 2017-05                  
R3 Discount Date: 2017-05-31 00:00:00                  
R4                  
R5    PartyName      PartyBix      Ranking
R6       AIG                     Insurance      1232
R7       Humana             Helthcare      3242
R8       Athena             Helthcare      3434
R9       BOA             bank              3431

Expected records in Table

Customer      Period      DiscountDate      PartyName      PartyBix              Ranking
Syntel              2017-05      5/31/2017              AIG                      Insurance      1232
Syntel              2017-05      5/31/2017              Humana              Helthcare      3242
Syntel              2017-05      5/31/2017              Athena              Helthcare      3434
Syntel              2017-05      5/31/2017              BOA              bank              3431

Regards
Pratik
sample_excel.xlsx
pratikkange7Asked:
Who is Participating?
 
Rgonzo1971Commented:
Like I said you have strExcelConn  
 strExcelConn = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" & strDestPath & "; Extended Properties='Excel 12.0;HDR=Yes;IMEX=1'"

change to
 strExcelConn = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" & strDestPath & "; Extended Properties='Excel 12.0;HDR=NO;IMEX=1'"
0
 
Rgonzo1971Commented:
Hi,

Is the XL connection  with HDR=YES or HDR=NO?

Regards
0
 
pratikkange7Author Commented:
Thanks..

Here it is:
       
strExcelConn = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & strDestPath & ";Extended Properties='Excel 8.0;HDR=Yes;IMEX=1'"
        If strExtension = ".xlsx" Or strExtension = ".XLSX" Then
            strExcelConn = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" & strDestPath & "; Extended Properties='Excel 12.0;HDR=Yes;IMEX=1'"
        End If
0
 
pratikkange7Author Commented:
Yes its working now. Its considering the R1 and values are populated.
Thanks a lot. Great Help in-time..
0
 
pratikkange7Author Commented:
Thanks..God Bless you..
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.