Hello Everyone!
Does someone have an example of how to open XLS file and read row and a certain column data? I need to run a computer (server) that does not have MS office and upload data SQL server.
Thank You!
CREATING XLSX FILES WITHOUT USING EXCEL APPLICATION.
oRs := FW_OpenADOExcelSheet( cXlsxFile, [cSheet], [cRange], [lHeaders] )
XBROWSER oRs
#include "FiveWin.ch"
FUNCTION Main()
Local cXlsxFile := "para_leer_xls.xlsx"
Local oRs,cValue01,cValue02
oRs := FW_OpenADOExcelSheet( cXlsxFile, "Hoja1", "A4:J62", .F. )
//XBROWSER oRs
oRs:MoveFirst()
Do While !oRs:Eof()
cValue01 := oRs:Fields("F1"):Value
cValue02 := oRs:Fields("F2"):Value
oRs:MoveNext()
EndDo
oRs:close()
return nil
cdmmaui wrote:I tried
oRs := FW_OpenADOExcelSheet( cSource, "Sheet1", "A1:SB65000", .T. )
And got the following errors
1. ADO ERROR UNKNOWN
2. Fail to open "XLS path + filename.XLSX"
FW_ShowXLSX( cFileXlsx )
cdmmaui wrote:Hi Rao,
Thank you. However, this XLS has 494 columns and about 23,000 rows. I am looking to start reading row 2 and only retrieve about 80 columns of data so I can upload to SQL. Is there a way to read data row by row like below?
cValue01 := oSheet:Cells( nCurrentXlsRow, 2 ):Value
cValue02 := oSheet:Cells( nCurrentXlsRow, 8 ):Value
cValue03 := oSheet:Cells( nCurrentXlsRow, 18 ):Value
cValue04 := oSheet:Cells( nCurrentXlsRow, 28 ):Value
cValue05 := oSheet:Cells( nCurrentXlsRow, 88 ):Value
Thanks Again for your support!
oSheet := FW_OpenXlsx( cFileNameXlsx)
nCurrentXlsRow := 19000 // or any
cValue01 := oSheet:Cells( nCurrentXlsRow, 2 )
cValue02 := oSheet:Cells( nCurrentXlsRow, 8 )
cValue03 := oSheet:Cells( nCurrentXlsRow, 18 )
cValue04 := oSheet:Cells( nCurrentXlsRow, 28 )
cValue05 := oSheet:Cells( nCurrentXlsRow, 88 )
// OR
aVals := oSheet:Cells( nCurrentXlsRow, { 2, 8, 18, 28, 88 } )
cValue01 := aVals[ 1 ]
....
cValue05 := aVals[ 5 ]
Return to FiveWin for Harbour/xHarbour
Users browsing this forum: No registered users and 96 guests