Home > Software engineering >  Using ado under vb reading excel merged cell
Using ado under vb reading excel merged cell

Time:09-27

In the excel spreadsheet, often have a row containing multiple merged cell field, when you use the read there will always be some read less than content, such as:
Excel spreadsheet content is as follows:

AA (a cell) BB (cell 1) CC (cell 1) DD (cell 2) EE (cell 2) FF (three cell) GG cells (3)
The code is probably:
 Excelcn="Provider=Microsoft. ACE. The OLEDB. 12.0;" & _ 
"Data Source" & amp; App. The Path & amp; "\ aa. XLS;" Extended Properties=8.0 "" Excel; HDR=YES." "
"Cn. Open Excelcn
Cn. CursorLocation=adUseClient
Rs. Open the "SELECT * FROM [Sheet1 $]", cn, adOpenStatic
Rs. MoveFirst
EOF
Do Until the rs.For j=0 To rs Fields. The Count - 1
The Debug. Print the rs (j)
Next j
Rs. MoveNext
Loop

Perform and found out the results of the FF is null
Cases such as: AA BB CC DD null EE null null null null GG null null
Why not: AA BB CC DD null EE null FF null null GG null null
Please help show just a little, how to complete to read?

CodePudding user response:

Master are willing to guide it to me?

CodePudding user response:

Well, it seems that no one

CodePudding user response:

Try:
 "Data Source" & amp; App. The Path & amp; "\ aa. XLS;" Extended Properties=8.0 "" Excel; HDR=YES; IMEX=1 "" "

CodePudding user response:

 "Data Source" & amp; App. The Path & amp; "\ aa. XLS;" Extended Properties=8.0 "" Excel; HDR=YES; IMEX=1;" "" 

CodePudding user response:

ADO as there is no way to directly, unless a excel object way

CodePudding user response:

It can be read correctly:
Not the same with you drive, use the most common,
IMEX must add,
 Excelcn="Provider=Microsoft. Jet. The OLEDB. 4.0;" & _ 
"Data Source=" & amp; App. The Path & amp; "\ aa. XLS;" & _
"Extended Properties=" Excel "8.0; HDR=YES; IMEX=1;" "
"Cn. Open Excelcn
Cn. CursorLocation=adUseClient
Rs. Open the "SELECT * FROM [Sheet1 $]", cn, adOpenStatic

Rs. MoveFirst
EOF
Do Until the rs.
For j=0 To rs Fields. The Count - 1
If j & gt; 0 Then the Debug. Print ", ";
The Debug. Print the rs (j);
Next j
The Debug. Print

Rs. MoveNext
Loop

CodePudding user response:

My test results and the building is different,
 Dim cn As New ADODB library. The Connection, the rs As New ADODB library. You, j As Long 

Cn. The Open ". The Provider=Microsoft Jet. The OLEDB. 4.0; Data Source=C: \ test \ test. XLS. Extended Properties=8.0 "" Excel; HDR=No. IMEX=1 ", "
"Rs. Open the "select * from [sheet1 $]", cn

EOF
Do Until the rs.For j=0 To rs Fields. The Count - 1
The Debug. Print the rs (j),
Next j

The Debug. Print
Rs. MoveNext
Loop
 aa bb cc dd Null ee Null ff Null Null gg Null Null 

CodePudding user response:

This reads as if can't read characters, mix the warrior have good method
  •  Tags:  
  • VBA
  • Related