FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour New: Read/Edit/Save XLSX files without Excel/ADO
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
New: Read/Edit/Save XLSX files without Excel/ADO
Posted: Tue Dec 24, 2024 04:32 AM
Next version of FWH under release enable reading, modifying and also saving the changes (to another xlsx file) without Excel or ACE OLEDB installed on the PC.

Simple Usage:
Code (fw): Select all Collapse
FW_ShowXLSX( cFileXlsx, [cSheet] ) // --> oXlsx object
Examples:
Code (fw): Select all Collapse
FW_ShowXLSX( "customer.xlsx" )

Code (fw): Select all Collapse
FW_ShowXLSX( "wwonders.xlsx" )


The browses are fully editable and the modified data can be saved to another xlsx file by clicking the Excel button.

DATAS AND METHODS
Code (fw): Select all Collapse
DATAS:
DATA cXlsx          // xlsx filename
DATA nRows,nCols  // size
DATA aHead  // header array
DATA aStruct
DATA aData  
ACCESS oData  // aData in the form of TArrayData

METHODS:
METHOD ReadData()         
METHOD ShowData()         
METHOD Range( cRange )    
METHOD Cells( nRow, [anCol] )
METHOD SaveAs( cSave )    
METHOD Close()/End()
Notes:
1. Reads only values and data types of the cells but does not read other formatting information like font character specs or other formatting like pictures, border styles, etc.
2. Reads only scalar data and embedded images from the cells but does not read Charts and other objects embedded in the sheet.
3. Saving will save only the current tab/sheet and does not save formatting information contained in the original xlsx file.
So, please never save by over-writing the original source file.

Size Limitations:
With 32-bit applications we may face limitations with very huge size of the xlsx file. We are testing but still not sure of the limitations.

We tested with xlsx files of the following sizes:
1) 9,000,000 rows, 12 cols and file size : 87,183,538 bytes
2) 32,000 rows, 502 columns and file size: 79,998,254 bytes
Every thing worked perfectly without any problems.
Regards



G. N. Rao.

Hyderabad, India
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: New: Read/Edit/Save XLSX files without Excel/ADO
Posted: Tue Dec 24, 2024 05:11 AM
Recommendations while using very large xlsx files:
In such cases, most of the times, we won't be interested in reading and browsing the entire table, but only extracting limited information required.
We may adopt this approach:
Code (fw): Select all Collapse
oXl := FW_OpenXlsx( cFileXlsx, [cSheet] )
? oXl:nRows, oXl:nCols
aData := oXl:Range( "E21100:H:21110" )
// use aData as required
aRowValues := oXl:Cells( nRow )
// array containing values of all columns in the row
aVals := oXl:Cells( nRow, { nCol1, nCol2, ... } )
// array of values in columns specified
uValue := oXl:Cells( nRow, nCol )
// value of a single cell

oXl:End()
oXl := nil
Regards



G. N. Rao.

Hyderabad, India
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: New: Read/Edit/Save XLSX files without Excel/ADO
Posted: Tue Dec 24, 2024 05:35 AM
Great work from Mr. Rao as usual :-)

Thank you very much!
regards, saludos

Antonio Linares
www.fivetechsoft.com

Continue the discussion