Arhivos xls y xlsm

Arhivos xls y xlsm

Postby servicomver » Mon Feb 01, 2021 1:40 am

Hola,¿ como puedo abrir y modificar un archivo xls, xlsx y xlsm ?
En una hoja especifica o en una hoja única


Gracias, Saludos
servicomver
 
Posts: 190
Joined: Fri Nov 18, 2005 7:34 pm

Re: Arhivos xls y xlsm

Postby nageswaragunupudi » Mon Feb 01, 2021 3:34 am

It is much simpler using the FWH builtin function
GetExcelBook( cFileFullPath ) --> oBook

Code: Select all  Expand view  RUN
if ( oBook := GetExcelBook( cExcelFileNameWithFullPath ) ) != nil
            oBook:Application:Visible := .t.
         endif
 


You can also opt for full code like this:
Code: Select all  Expand view  RUN
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.
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10662
Joined: Sun Nov 19, 2006 5:22 am
Location: India


Return to FiveWin para Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 96 guests