Page 1 of 1
Arhivos xls y xlsm
Posted: Mon Feb 01, 2021 1:40 am
by servicomver
Hola,¿ como puedo abrir y modificar un archivo xls, xlsx y xlsm ?
En una hoja especifica o en una hoja única
Gracias, Saludos
Re: Arhivos xls y xlsm
Posted: Mon Feb 01, 2021 3:34 am
by nageswaragunupudi
It is much simpler using the FWH builtin function
GetExcelBook( cFileFullPath ) --> oBook
Code: Select all
if ( oBook := GetExcelBook( cExcelFileNameWithFullPath ) ) != nil
oBook:Application:Visible := .t.
endif
You can also opt for full code like this:
Code: Select all
function OpenExcelBook()
local cExcelFile := "import.xlsx"
local oExcel, oBook, lOpened := .f.
if File( cExcelFile )
cExcelFile := TrueName( cExcelFile ) // add full path
CursorWait()
if ( oExcel := ExcelObj() ) != nil
TRY
oBook := oExcel:WorkBooks:Open( cExcelFile )
lOpened := .t.
CATCH
END
if lOpened
oExcel:Visible := .t.
else
? "Can not open " + cExcelFile
endif
else
? "Excel not installed"
endif
else
? cExcelFile + " not found"
endif
return nil
We recommend the first approach.