Exporting data in Libreoffice Calc

351 views
Skip to first unread message

Rajko

unread,
Nov 27, 2017, 7:31:18 AM11/27/17
to Harbour Users
Hi, is there any explicit way of invoking Libreoffice Calc instead of Openoffice, I need to have both versions installed but when I run

oServiceManager := CreateObject( "com.sun.star.ServiceManager" )
oDesktop
:= ::oServiceManager:createInstance( "com.sun.star.frame.Desktop" )

I always start Open office.Thanks, Rajko.

Miraš Ćirović

unread,
Nov 30, 2017, 10:36:12 AM11/30/17
to harbou...@googlegroups.com
Hi Rajko,

This is my procedure for Libre. I hope that is what You looking.

I hope it will help you.

Procedure SnimiCalc()
local oServiceManager,oDesktop,oDocument,oSchedule,oSheet,oCell,oColums,oColumn,cDatXls

 // inicijalizacija
 *IF ( oServiceManager := win_oleCreateObject( "com.sun.star.ServiceManager" ) ) != NIL
 IF (  oServiceManager := TOleAuto():New("com.sun.star.ServiceManager") ) != NIL

   oDesktop := oServiceManager:createInstance("com.sun.star.frame.Desktop")
   IF oDesktop = NIL
      MsgStop('OpenOffice Calc nije instaliran','error')
      RETURN Nil
   ENDIF
   cDatXls := GetStartUpFolder() + "\" +"GFI-POD.xls"
   IF FILE(cDatXls)
      cDatXls:="file:///"+cDatXls
      oDocument := oDesktop:loadComponentFromURL(cDatXls,"_blank", 0, {})
   ELSE
      oDocument := oDesktop:loadComponentFromURL("private:factory/scalc","_blank", 0, {})
   ENDIF
   oSchedule := oDocument:GetSheets() 
   oSheet := oSchedule:GetByName("Opci")
   oSheet:getCellRangeByName( "E5" ):setString(ctod("01.01."+TE_GODINA) )
   oSheet:getCellRangeByName( "H5" ):setString(ctod("31.12."+TE_GODINA) )
   oSheet:getCellRangeByName( "E9" ):setValue( 5 )
   oSheet:getCellRangeByName( "C17" ):setValue( 10 )
   oSheet:getCellRangeByName( "G14" ):setString( TE_GODINA )
   oSheet:getCellRangeByName( "C19" ):setString( Fmaticni )
   oSheet:getCellRangeByName( "C21" ):setString( FMBS )
   oSheet:getCellRangeByName( "C23" ):setString( FIOB )
   oSheet:getCellRangeByName( "C25" ):setString( Faktiv )
   oSheet:getCellRangeByName( "C27" ):setString( FPTT )
   oSheet:getCellRangeByName( "F27" ):setString( Fmjesto )
   oSheet:getCellRangeByName( "C29" ):setString( Fadresa )
   oSheet:getCellRangeByName( "C31" ):setString( Femail )        //EMAIL ADRESA
   oSheet:getCellRangeByName( "C35" ):setString(FSifOPC)       //ŠIFRA OPĆINE GRADA
 *  oSheet:getCellRangeByName( "C37" ):setString(FSifOPC)       //ŠIFRA ŽUPANIJE     SAM ODREDI OD ŠIFRE OPĆINE
   oSheet:getCellRangeByName( "C45" ):setValue( FSvrhaPred )    //SVRHA PREDAJE
   oSheet:getCellRangeByName( "C47" ):setValue( FOzVel )    //OZNAKA VELIČINE
   oSheet:getCellRangeByName( "C49" ):setString( FOzVlas )    //OZNAKA VLASNIŠTVA
   oSheet:getCellRangeByName( "C51" ):setValue( FDomKap )    //DOMAĆI KAPITAL
   oSheet:getCellRangeByName( "E51" ):setValue( FStrKap )    //STRANI KAPITAL
   oSheet:getCellRangeByName( "C67" ):setString( Ftelefon )    //KONTAKT TELEFON
   oSheet:getCellRangeByName( "H67" ):setString( FFax )    //KONTAKT FAX
   oSheet:getCellRangeByName( "H69" ):setString( "" )    //ADRESA E POŠTE
   oSheet:getCellRangeByName( "C65" ):setString( FosobazaKon )    //FOSOBAZAS       //osoba za kontakt
   oSheet:getCellRangeByName( "C71" ):setString( FosobazaZast )    //FOSOBAZAS       //OVLAŠTENA OSOBA

  SELECT FPOZICIJ
  GO TOP
  DBSEEK(FOBRASCI->SIFOBR)
  oSheet := oSchedule:GetByName("Bilanca")
  WHILE FPOZICIJ->SIFOBR == FOBRASCI->SIFOBR .AND. !EOF()
       IF !EMPTY(FPOZICIJ->EXCELPRED) .and. FPOZICIJ->PREDHODNA <> 0
          oSheet:getCellRangeByName(ALLTRIM(FPOZICIJ->EXCELPRED)):setValue(ROUND(FPOZICIJ->PREDHODNA,0))
          *oHoja:Range(ALLTRIM(FPOZICIJ->EXCELPRED)):Value := FPOZICIJ->PREDHODNA
       ENDIF
       IF !EMPTY(FPOZICIJ->EXCELTEK) .and. FPOZICIJ->NETO <> 0 
          oSheet:getCellRangeByName(ALLTRIM(FPOZICIJ->EXCELTEK)):setValue(ROUND(FPOZICIJ->NETO,0))
       
          *oHoja:Range(ALLTRIM(FPOZICIJ->EXCELTEK)):Value := FPOZICIJ->NETO
       ENDIF  
    IF FPOZICIJ->POZICIJA = "rdg"
           oSheet := oSchedule:GetByName("RDG")
           *oExcel:Set("RDG",.F.) //
           *oExcel:Sheets("RDG"):Select()
           *oHoja:=oExcel:Get( "ActiveSheet" )
    ENDIF      
    IF FPOZICIJ->POZICIJA = "dod"
           oSheet := oSchedule:GetByName("PodDop")
   
           *oExcel:Set("PodDop",.F.) //
           *oExcel:Sheets("PodDop"):Select()
           *oHoja:=oExcel:Get( "ActiveSheet" )
    ENDIF
    DBSKIP()
  END
ENDIF
Return

Best regards.
Miraš Ćirović


--
--
You received this message because you are subscribed to the Google
Groups "Harbour Users" group.
Unsubscribe: harbour-users+unsubscribe@googlegroups.com
Web: http://groups.google.com/group/harbour-users

---
You received this message because you are subscribed to the Google Groups "Harbour Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to harbour-users+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Rajko

unread,
Dec 1, 2017, 3:33:15 AM12/1/17
to Harbour Users
Thank you very much for your effort but that's not the problem, I have Openoffice and Libreoffice installed because I need Openoffice for small portion of work, but I would like to use Libreoffice for everything else, I know that they are almost identical but it's just bugging me exporting to Openoffice and the saving and loading same document with Libreoffice :). I tried to find something on web, but I don't think it's possible.Thanks, Rajko.

Klas Engwall

unread,
Dec 1, 2017, 5:41:45 AM12/1/17
to harbou...@googlegroups.com
Hi Rajko,

> I have
> Openoffice and Libreoffice installed because I need Openoffice for small
> portion of work, but I would like to use Libreoffice for everything
> else, I know that they are almost identical but it's just bugging me
> exporting to Openoffice and the saving and loading same document with
> Libreoffice :). I tried to find something on web, but I don't think it's
> possible.Thanks, Rajko.

So it is a question of convincing Windows which of the installed OLE
servers to call. This is really the same problem as having an old and a
new version of the same application installed.

Try to cd to the directory where Libre Office scalc.exe is installed.
That would be something like "C:\Program\LibreOffice 5\program". Then
start scalc.exe with the "/register" argument (without the quotes). I
can give you no guarantees :-) but I found that solution at the MatLab
website, where a plugin developer had many different MatLab versions
installed at the same time. The idea with "/register" is to force
Windows to put that application version at the top of the list of
identical OLE servers.

https://se.mathworks.com/matlabcentral/answers/44849-register-com-matlab-application-tlb-for-certain-version-on-when-multiple-versions-installed

Regards,
Klas

Rajko

unread,
Dec 4, 2017, 8:50:23 AM12/4/17
to Harbour Users


On Friday, December 1, 2017 at 11:41:45 AM UTC+1, Klas Engwall wrote:

So it is a question of convincing Windows which of the installed OLE
servers to call. This is really the same problem as having an old and a
new version of the same application installed.

Try to cd to the directory where Libre Office scalc.exe is installed.
That would be something like "C:\Program\LibreOffice 5\program". Then
start scalc.exe with the "/register" argument (without the quotes). I
can give you no guarantees :-) but I found that solution at the MatLab
website, where a plugin developer had many different MatLab versions
installed at the same time. The idea with "/register" is to force
Windows to put that application version at the top of the list of
identical OLE servers.


Thank you Klas for your reply, I tried with no success but now I have direction where to search. Thank you very much. Rajko
Reply all
Reply to author
Forward
0 new messages