Open XLS without Excel
- cdmmaui
- Posts: 693
- Joined: Fri Oct 28, 2005 9:53 am
- Location: Houston ∙ Chicago ∙ Los Angeles ∙ Miami ∙ London ∙ Hong Kong
- Contact:
Open XLS without Excel
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!
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!
- Marc Venken
- Posts: 1481
- Joined: Tue Jun 14, 2016 7:51 am
- Location: Belgium
Re: Open XLS without Excel
From WhatsNew.txt
CREATING XLSX FILES WITHOUT USING EXCEL APPLICATION.
Recently two great libraries to create xlsx files without
using Excel have been released for free use by Harbour
community.
1. DrXlsx library by Dr Charles Kwon.
see: https://forums.fivetechsupport.com/view ... =3&t=43643
Library download link: http://www.charleskwon.com/?page_id=956
2. xlxlib by Mr. John McNamara and Mr. Arturo Tamayo Daza
see: https://forums.fivetechsupport.com/view ... =3&t=43767
Library download link: https://github.com/FiveTechSoft/FWH_too ... b_ver2.zip
- Any one or both these libraries can be downloaded and linked with
FWH application. FWH further provides wrapper classes for these libraries
to make it more convenient to use these libraries.
Please see: \fwh\source\function\drxl.prg and \fwh\source\function\fwxlsxlb.prg
To force these classes, use
REQUEST DRXLSX
REQUEST XLXLIB
as the case may be.
- Interested users can download these libs to \fwh\libs folder,
BUILD??.BAT files provide the link scripts,
To use these libs, remove "rem " before the relevant link script
CREATING XLSX FILES WITHOUT USING EXCEL APPLICATION.
Recently two great libraries to create xlsx files without
using Excel have been released for free use by Harbour
community.
1. DrXlsx library by Dr Charles Kwon.
see: https://forums.fivetechsupport.com/view ... =3&t=43643
Library download link: http://www.charleskwon.com/?page_id=956
2. xlxlib by Mr. John McNamara and Mr. Arturo Tamayo Daza
see: https://forums.fivetechsupport.com/view ... =3&t=43767
Library download link: https://github.com/FiveTechSoft/FWH_too ... b_ver2.zip
- Any one or both these libraries can be downloaded and linked with
FWH application. FWH further provides wrapper classes for these libraries
to make it more convenient to use these libraries.
Please see: \fwh\source\function\drxl.prg and \fwh\source\function\fwxlsxlb.prg
To force these classes, use
REQUEST DRXLSX
REQUEST XLXLIB
as the case may be.
- Interested users can download these libs to \fwh\libs folder,
BUILD??.BAT files provide the link scripts,
To use these libs, remove "rem " before the relevant link script
Marc Venken
Using: FWH 23.08 with Harbour
Using: FWH 23.08 with Harbour
- nageswaragunupudi
- Posts: 10691
- Joined: Sun Nov 19, 2006 5:22 am
- Location: India
- Contact:
Re: Open XLS without Excel
They are for creating only. Not for readingCREATING XLSX FILES WITHOUT USING EXCEL APPLICATION.
Regards
G. N. Rao.
Hyderabad, India
G. N. Rao.
Hyderabad, India
- Marc Venken
- Posts: 1481
- Joined: Tue Jun 14, 2016 7:51 am
- Location: Belgium
- nageswaragunupudi
- Posts: 10691
- Joined: Sun Nov 19, 2006 5:22 am
- Location: India
- Contact:
Re: Open XLS without Excel
Try opening an xlsx file with
Code: Select all | Expand
oRs := FW_OpenADOExcelSheet( cXlsxFile, [cSheet], [cRange], [lHeaders] )
XBROWSER oRs
Regards
G. N. Rao.
Hyderabad, India
G. N. Rao.
Hyderabad, India
- cdmmaui
- Posts: 693
- Joined: Fri Oct 28, 2005 9:53 am
- Location: Houston ∙ Chicago ∙ Los Angeles ∙ Miami ∙ London ∙ Hong Kong
- Contact:
Re: Open XLS without Excel
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!
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!
Re: Open XLS without Excel
Una idea
Code: Select all | Expand
#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
Saludos
LEANDRO AREVALO
Bogotá (Colombia)
https://hymlyma.com
https://hymplus.com/
leandroalfonso111@gmail.com
leandroalfonso111@hotmail.com
[ Embarcadero C++ 7.60 for Win32 ] [ FiveWin 23.07 ] [ xHarbour 1.3.0 Intl. (SimpLex) (Build 20230914) ]
LEANDRO AREVALO
Bogotá (Colombia)
https://hymlyma.com
https://hymplus.com/
leandroalfonso111@gmail.com
leandroalfonso111@hotmail.com
[ Embarcadero C++ 7.60 for Win32 ] [ FiveWin 23.07 ] [ xHarbour 1.3.0 Intl. (SimpLex) (Build 20230914) ]
- cdmmaui
- Posts: 693
- Joined: Fri Oct 28, 2005 9:53 am
- Location: Houston ∙ Chicago ∙ Los Angeles ∙ Miami ∙ London ∙ Hong Kong
- Contact:
Re: Open XLS without Excel
Hola Leandro, Gracias!
- cdmmaui
- Posts: 693
- Joined: Fri Oct 28, 2005 9:53 am
- Location: Houston ∙ Chicago ∙ Los Angeles ∙ Miami ∙ London ∙ Hong Kong
- Contact:
Re: Open XLS without Excel
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"
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"
- nageswaragunupudi
- Posts: 10691
- Joined: Sun Nov 19, 2006 5:22 am
- Location: India
- Contact:
Re: Open XLS without Excel
By default, Microsoft Jet OLEDB is installed on every PC.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"
This default Jet OLEDB can open only "xls" files but not "xlsx" files using ADO.
You can right now try xls (not xlsx) files and you can open them.
To open xlsx files using ADO, you need to download and install Microsoft ACE.OLEDB version 16 and try.
One headache with these products is the confusion between 32/64 bit. Please try to install 32 bit version and try.
Lastly, if we want our application to run on any PC without intalling additional drivers, the best thing is to write our own fwh program to "raw" read directly from xlsx file.
I did this work earlier and left it without completely finishing it.
Let me try again
Regards
G. N. Rao.
Hyderabad, India
G. N. Rao.
Hyderabad, India
- nageswaragunupudi
- Posts: 10691
- Joined: Sun Nov 19, 2006 5:22 am
- Location: India
- Contact:
Re: Open XLS without Excel
We are working on a new function
This is still needs to be finalized.
No libraries, drivers or OleDB providers are required.
This function directly reads from the xlsx file and extracts the data.
So this is guaranteed to work on an computer.
Example out put:
If you like send any large xlslx file, I can try to test this function and fine tune it.
Note: This can read only xlsx files but not the older xls files
Code: Select all | Expand
FW_ShowXLSX( cFileXlsx )
No libraries, drivers or OleDB providers are required.
This function directly reads from the xlsx file and extracts the data.
So this is guaranteed to work on an computer.
Example out put:
If you like send any large xlslx file, I can try to test this function and fine tune it.
Note: This can read only xlsx files but not the older xls files
Regards
G. N. Rao.
Hyderabad, India
G. N. Rao.
Hyderabad, India
- nageswaragunupudi
- Posts: 10691
- Joined: Sun Nov 19, 2006 5:22 am
- Location: India
- Contact:
Re: Open XLS without Excel
Is your Excel file XLS or XLSX ?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!
If this is XLSX we can use our new class:
Usage:
Code: Select all | Expand
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 ]
Regards
G. N. Rao.
Hyderabad, India
G. N. Rao.
Hyderabad, India