FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index All products support dati da excel di openoffice
Posts: 340
Joined: Thu Jan 25, 2007 03:53 PM
dati da excel di openoffice
Posted: Mon Nov 15, 2010 05:02 PM

CIao,

avevo recuperato in giro una programmino con il quale riuscivo a recuperare i dati da un foglio excel di Microsoft)

Ora pero' volevo recuperare i dati da un foglio excel di OpenOffice. Ma lo stesso programma non funziona.
Avete qualcosa su cui "spataccare" ?

Grazie

Romeo/Zingoni

Posts: 9020
Joined: Thu Oct 06, 2005 08:17 PM
Re: dati da excel di openoffice
Posted: Mon Nov 15, 2010 06:42 PM
Qualche linea di codice:

Code (fw): Select all Collapse
oSrvMan  = CREATEOBJECT( "com.sun.star.ServiceManager" )
oDesktop = oSrvMan:CreateInstance( "com.sun.star.frame.Desktop" )

oDoc = oDesktop:LoadComponentFromURL( "private:factory/scalc", "_blank", 0, {} )

oSheet = oDoc:GetSheets():GetByIndex( 0 )

? oSheet:GetCellByPosition( 0, 0 ):GetString


EMG
Posts: 340
Joined: Thu Jan 25, 2007 03:53 PM
Re: dati da excel di openoffice
Posted: Wed Nov 17, 2010 10:47 AM

Grazie,
Ho provato ma canno da qualche parte.

Il mio file di excel di openoffice, che si chiama pippo.ods

Intanto dove fa messo nella tua procedura ?
Xche' io devo prendere dei dati da un foglio excel di openoffice GIA' ESISTENTE.

Romeo/Zingoni

Posts: 9020
Joined: Thu Oct 06, 2005 08:17 PM
Re: dati da excel di openoffice
Posted: Wed Nov 17, 2010 10:56 AM

Purtroppo non ho altri esempi. Guarda anche nel sorgente xbrowse.prg oppure cerca su Internet.

EMG

Posts: 340
Joined: Thu Jan 25, 2007 03:53 PM
Re: dati da excel di openoffice
Posted: Thu Mar 10, 2011 06:33 PM

Salve,

partendo da un esempietto di EMG e manipolandolo, qualcosa ho combinato.
...
... minimizzando il problema:

oSrvMan = CREATEOBJECT( "com.sun.star.ServiceManager" )
oDesktop = oSrvMan:CreateInstance( "com.sun.star.frame.Desktop" )

aProp:={}
aadd(aProp,GetPropertyValue(oSrvMan,"Hidden",.t.))

oDoc = oDesktop:LoadComponentFromURL("file:///c:/pippo.ods", "_blank",0, aProp)

oSheet = oDoc:GetSheets():GetByIndex( 0 )

miocampo=oSheet:GetCellByPosition( 0, 0 ):GetString
.
.
.
fine programma
....
Se clicco ora su Open Office, non parte perche' e' rimasto aperto, anche se invisibile, con il file pippo.ods aperto.

Come si fa a chiuderle OpenOffice e quindi liberare anche pippo.ods con fivewin/harbour ?

Ho provato con quit(), end() ecc agendo su: osheet, oDoc, oDesktop, oSrvMan ma mi da sempre errore.

Grazie
Romeo ZIngoni

Continue the discussion