FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin para Harbour/xHarbour Llamar BrOffice.org en lugar de Excel?
Posts: 8515
Joined: Tue Dec 20, 2005 07:36 PM
Llamar BrOffice.org en lugar de Excel?
Posted: Mon Oct 03, 2016 06:50 PM
Como Llamar BrOffice.org en lugar de Excel?

http://imgur.com/a/uyrqh



Gracias, saludos.
João Santos - São Paulo - Brasil - Phone: +55(11)95150-7341
Posts: 8515
Joined: Tue Dec 20, 2005 07:36 PM
Re: Llamar BrOffice.org en lugar de Excel?
Posted: Thu Oct 06, 2016 07:44 PM
/*
Usando BrOffice.org com Harbour e xHarbour

https://groups.google.com/forum/#!topic ... a8wwE54TRQ
*/

Code (fw): Select all Collapse
#include "FiveWin.ch"

function main ()

   local oServiceManager
   local oDesktop
   local oDocument
   local oSchedule
   local oSheet
   local oCell
   local oColums
   local oColumn
   local a1
   local a2
   local i

   // inicializa
   oServiceManager := TOleAuto():New("com.sun.star.ServiceManager")

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

   oDocument := oDesktop:loadComponentFromURL("private:factory/scalc","_blank", 0, {})

   // obtem planilhas
   oSchedule := oDocument:GetSheets()
   // obtem a primeira planilha
   // por nome
   //oSheet := oSchedule:GetByName("Planilha1")
   // ou
   // por indice
   oSheet := oSchedule:GetByIndex(0)

   // meses
   a1 := {"Janeiro","Fevereiro","Março","Abril","Maio","Junho","Julho","Agosto","Setembro","Outubro","Novembro","Dezembro"}

   // valores
   a2 := {100,200,300,400,500,600,700,800,900,1000,1100,1200}

   for i := 1 to 12

      // escreve texto na linha I da coluna A
      oCell := oSheet:getCellByPosition(0,i-1)
      oCell:SetString(a1[i])

      // escreve valor na linha I da coluna B
      oCell := oSheet:getCellByPosition(1,i-1)
      oCell:SetValue(a2[i])
      oCell:NumberFormat := 2 // configura formato para 2 casas decimais

   next i

   // soma celulas de B1 a B12 usando uma formula

   oCell := oSheet:getCellByPosition(0,13)
   oCell:SetString("Total:")

   oCell := oSheet:getCellByPosition(1,13)
   oCell:Formula := "=SUM(B1:B12)"
   oCell:NumberFormat := 2

return nil


João Santos - São Paulo - Brasil - Phone: +55(11)95150-7341
Posts: 6755
Joined: Wed Feb 15, 2012 08:25 PM
Re: Llamar BrOffice.org en lugar de Excel?
Posted: Thu Oct 06, 2016 08:47 PM

Joao, gracias

Cristobal Navarro

Hay dos tipos de personas: las que te hacen perder el tiempo y las que te hacen perder la noción del tiempo

El secreto de la felicidad no está en hacer lo que te gusta, sino en que te guste lo que haces

Continue the discussion