Hi,
I am trying to import data from excel sheet to data table. Below code worked last week and I was able to import data from excel to data table. But when I try today, It is nor retrieving correct sheet name. Sheet name is displayed as "JR_PAGE_ANCHOR_0_1". Please help me in resolving the issue. Below is the code I am using.
strxlconn = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" & UIFile & ";Extended Properties=""Excel 12.0 Xml;HDR=YES"";"
Dim xlconn as System.Data.OleDb.OleDbConnection = new System.Data.OleDb.OleDbConnection(strxlconn)
xlconn.Open
Dim dtTablelist as System.Data.DataTable = xlconn.GetSchema("Tables")
UIDataDT = New System.Data.DataTable()
If dtTablelist.Rows.Count > 0 Then
sheetname = dtTablelist.Rows(0)("TABLE_NAME").ToString
System.Console.WriteLine ("First Sheet name is: " & sheetname )
report.Log(reportlevel.Info, "Sheet name is " & sheetname)
End If
If sheetname <> "" Then
xlcmd = New OleDbCommand("select * from [" & sheetname & "]", xlconn)
xladp = New OleDbDataAdapter(xlcmd)
xladp.Fill(UIDataDT)
System.Console.WriteLine("UI Data loaded into data table")
uirowcount = UIDataDT.Rows.Count.ToString
System.Console.WriteLine("Number of rows in UI data tableis " & uirowcount)
uicolcount = UIDataDT.Columns.Count.ToString
System.Console.WriteLine("Number of columns in UI data tableis " & uicolcount)
xlconn.Close
report.Log(reportlevel.Info, "UI Data loaded into data table")
report.Log(reportlevel.Info, "Number of rows in UI data table is " & uirowcount)
End If
Thanks
Vivek
excel sheet name is displayed as jr_page_anchor_0_1
-
- Posts: 31
- Joined: Mon Feb 22, 2016 7:21 pm
Re: excel sheet name is displayed as jr_page_anchor_0_1
If it worked last week, then what changed between now and then? That is probably what is causing the issue.
Look in your version control system and you should be able to see what changed. That should give you a pretty good clue as to what to fix.
Look in your version control system and you should be able to see what changed. That should give you a pretty good clue as to what to fix.
Shortcuts usually aren't...