Llamar BrOffice.org en lugar de Excel?

Llamar BrOffice.org en lugar de Excel?

Postby karinha » Mon Oct 03, 2016 6:50 pm

Como Llamar BrOffice.org en lugar de Excel?

http://imgur.com/a/uyrqh

Image

Gracias, saludos.
João Santos - São Paulo - Brasil - Phone: +55(11)95150-7341
User avatar
karinha
 
Posts: 7613
Joined: Tue Dec 20, 2005 7:36 pm
Location: São Paulo - Brasil

Re: Llamar BrOffice.org en lugar de Excel?

Postby karinha » Thu Oct 06, 2016 7:44 pm

/*
Usando BrOffice.org com Harbour e xHarbour

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

Code: Select all  Expand view

#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
User avatar
karinha
 
Posts: 7613
Joined: Tue Dec 20, 2005 7:36 pm
Location: São Paulo - Brasil

Re: Llamar BrOffice.org en lugar de Excel?

Postby cnavarro » Thu Oct 06, 2016 8: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
User avatar
cnavarro
 
Posts: 6522
Joined: Wed Feb 15, 2012 8:25 pm
Location: España


Return to FiveWin para Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 23 guests