READ XLSx with ADO (without Excel)
Posted: Sat May 30, 2020 5:54 am
hi,
i found Sample c:\MiniGUI\SAMPLES\Advanced\ReadXLS_2\ReadExcel.PRG
it work fine but i have a Problem with "unknown" XLSx how to get 1st Sheet Name
default it is "Sheet1" but if User have use different Name ...
using ActiveX i can "Set" Sheet Name using
i found Sample c:\MiniGUI\SAMPLES\Advanced\ReadXLS_2\ReadExcel.PRG
it work fine but i have a Problem with "unknown" XLSx how to get 1st Sheet Name

default it is "Sheet1" but if User have use different Name ...
Code: Select all
objRS1 := CreateObject( 'ADODB.Recordset' )
strRange := mySheet + '$' // ALL
// strRange := mySheet + "$" + my1stCell + ":" + myLastCell
BEGIN SEQUENCE
objRS1:Open( "Select count(*) from [" + strRange + "]", objExcel, adOpenStatic )
DO WHILE .NOT. objRS1:EOF()
nMaxLen := MAX( nMaxLen, objRS1:Fields( 0 ) :Value() )
objRS1:MoveNext()
ENDDO
objRS1:Close()
RECOVER USING oError
ERRORBLOCK( bError )
MsgStop( "Operation: " + oError:Operation + " - Description: " + oError:Description, "Error" )
RETURN
END SEQUENCE
ERRORBLOCK( bError )
Code: Select all
oExcel:Application:Worksheets(1):name := ID_USER