Arhivos xls y xlsm

Post Reply
servicomver
Posts: 158
Joined: Fri Nov 18, 2005 7:34 pm

Arhivos xls y xlsm

Post 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
User avatar
nageswaragunupudi
Posts: 8017
Joined: Sun Nov 19, 2006 5:22 am
Location: India
Contact:

Re: Arhivos xls y xlsm

Post 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.
Regards

G. N. Rao.
Hyderabad, India
Post Reply