Ernesto_Paez
MIS
Hi Everyone,
i am using these two functions to pass the cursor data and create an excel file but the file created, is "xlsx type" and the person who is running the application still using Ms office 2010, so he is getting this error "OLE mismatch errors" However while running the same application on a machine having Ms office 2016 ,there is not problem excel open as XLSX.
any help is very well appreciated plus also the reason why is this happening ?
I don't know if this happening because of the code below, otherwise please excuse me.
Thanks a lot
i am using these two functions to pass the cursor data and create an excel file but the file created, is "xlsx type" and the person who is running the application still using Ms office 2010, so he is getting this error "OLE mismatch errors" However while running the same application on a machine having Ms office 2016 ,there is not problem excel open as XLSX.
any help is very well appreciated plus also the reason why is this happening ?
I don't know if this happening because of the code below, otherwise please excuse me.
Thanks a lot
Code:
Function VFP2ExcelVariation(toStream, toRange, tcHeaders)
Local loRS As AdoDb.Recordset,ix
loRS = Createobject('Adodb.Recordset')
m.loRS.Open( m.toStream )
* Use first row for headers
Local Array aHeader[1]
m.toRange.Offset(1,0).CopyFromRecordSet( m.loRS ) && Copy data starting from headerrow + 1
For ix=1 To Iif( !Empty(m.tcHeaders), ;
ALINES(aHeader, m.tcHeaders,1,','), ;
m.loRS.Fields.Count )
m.toRange.Offset(0,m.ix-1).Value = ;
Iif( !Empty(m.tcHeaders), ;
aHeader[m.ix], ;
Proper(m.loRS.Fields(m.ix-1).Name) )
m.toRange.Offset(0,m.ix-1).Font.Bold = .T.
Endfor
m.loRS.Close()
Endfunc
Procedure GetDataAsAdoStream(tcConnection, tcSQL)
Local loStream As 'AdoDb.Stream', ;
loConn As 'AdoDb.Connection', ;
loRS As 'AdoDb.Recordset'
loStream = Createobject('AdoDb.Stream')
loConn = Createobject("Adodb.connection")
loConn.ConnectionString = m.tcConnection
m.loConn.Open()
loRS = loConn.Execute(m.tcSQL)
m.loRS.Save( loStream )
m.loRS.Close
m.loConn.Close
Return m.loStream
ENDPROC