1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

  2. Anuncie Aqui ! Entre em contato fdantas@4each.com.br

Integração progress X Libre Office

Discussão em 'Progress 4GL' iniciado por HumbertoOrtiz, Maio 12, 2016.

  1. HumbertoOrtiz

    HumbertoOrtiz Membro Participativo

    Bom dia.
    Alguém já desenvolveu um programa para gerar uma planilha no Libre Office(calc)
    vai comando progress.
    Preciso converter um programa que gera em Excel para o Libre Office.
    Se alguém puder me ajudar com um exemplo fico grato.
    Mesmo que seja bem básico, para iniciar e entender o funcionamento.
  2. bootstrapmaster

    bootstrapmaster Moderator Moderador Equipe de Suporte

    Da uma busca nos posts, tem até exemplo, de forma simples, mas tem.
    rhemati curtiu isso.
  3. lhp.s

    lhp.s Membro Participativo

    Código:
    def var BrOffice as com-handle.
    def var Desktop as com-handle.
    def var Planilha as com-handle.
    def var Documento as com-handle.
    def var Padrao as com-handle.
    def var Cabecalho as com-handle.
    def var Rodape as com-handle.
    def var Borda  as com-handle.
    def var Celula as com-handle.
    def var cc as raw.
    def var loop as int.
    def var vArq as char.
    
    &Global-Define Padrao 0
    &Global-Define Esquerda 1
    &Global-Define Centro 2
    &Global-Define Direita 3
    &Global-Define Justificar 4
    &Global-Define Repetir 5
    &Global-Define Cima 1
    &Global-Define Baixo 3
    
    &Global-Define black  0
    &Global-Define dark-blue  128
    &Global-Define dark-green  32768
    &Global-Define dark-cyan  32896
    &Global-Define dark-red  8388608
    &Global-Define dark-magenta  8388736
    &Global-Define dark-yellow  8421376
    &Global-Define dark-gray  8421504
    &Global-Define gray  12632256
    &Global-Define blue  255
    &Global-Define green  65280
    &Global-Define cyan  65535
    &Global-Define red  16711680
    &Global-Define magenta  16711935
    &Global-Define yellow  16776960
    &Global-Define white  16777215
    &Global-Define light-gray  15000804
    &Global-Define light-blue  33023
    &Global-Define light-green  8454016
    &Global-Define light-cyan  8454143
    &Global-Define light-red  16744576
    &Global-Define light-magenta  16744703
    &Global-Define light-yellow  16777088
    
    
    vArq = "file:///L:/teste.xls".
    
    create "com.sun.star.ServiceManager" BrOffice.
    
    Desktop = BrOffice:createinstance("com.sun.star.frame.Desktop").
    
    /*
    /* Abre um documento existente no disco */
    Documento = Desktop:loadComponentFromURL(vArq,"_blanck",0,cc).
    */
    
    /* Inicia um documento novo em branco */
    Documento = Desktop:loadComponentFromURL("private:factory/scalc","_default",0,cc).
    
    
    /* Remove Planilhas padrao */
    do while Documento:getSheets:getCount > 1:
      Planilha = Documento:getSheets:getByIndex(1).
      Documento:getSheets:removeByName( Planilha:name ).
    end.
    
    assign
      Planilha = Documento:getSheets:getByIndex(0).
      Planilha:name = "Minha Planilha".
    
    
    /* Personalisando Cabecalho e Rodape */
    Padrao = Documento:StyleFamilies:getByName("PageStyles"):getByName("Default").
    Padrao:headerIsOn = yes.
    Cabecalho = Padrao:RightPageHeaderContent.
    Cabecalho:LeftText:setString("Texto a Esquerda").
    Cabecalho:CenterText:setString("Texto Centralizado").
    Cabecalho:RightText:setString("Texto a Direita").
    Padrao:RightPageHeaderContent = Cabecalho.
    
    Padrao:footerIsOn = yes.
    Rodape = Padrao:RightPageFooterContent.
    Rodape:LeftText:setString("Texto a Esquerda").
    Rodape:CenterText:setString("Texto Centralizado").
    Rodape:RightText:setString("Texto a Direita").
    Padrao:RightPageFooterContent = Rodape.
    
    
    Planilha:GetCellByPosition(0,0):string = "Teste".
    Planilha:GetCellByPosition(0,0):HoriJustify = {&Centro}.
    Planilha:GetCellByPosition(0,0):VertJustify = {&Centro}.
    Planilha:GetCellByPosition(0,0):CharUnderline = 18. /* Sublinhado de 1 a 18 */
    
    
    Planilha:GetCellByPosition(1,0):value = 78.
    Planilha:GetCellByPosition(1,0):HoriJustify = {&Padrao}.
    Planilha:GetCellByPosition(1,0):VertJustify = {&Centro}.
    
    Planilha:GetCellByPosition(0,1):string = "Teste".
    Planilha:GetCellByPosition(0,1):HoriJustify = {&Centro}.
    Planilha:GetCellByPosition(0,1):VertJustify = {&Centro}.
    Planilha:GetCellByPosition(0,1):CharWeight = 200. /* Negrito */
    
    
    Planilha:GetCellByPosition(1,1):value = 123.
    Planilha:GetCellByPosition(1,1):HoriJustify = {&Padrao}.
    Planilha:GetCellByPosition(1,1):VertJustify = {&Centro}.
    
    Planilha:GetCellByPosition(0,2):string = "Ajuste automatico da lagura da coluna".
    
    Planilha:GetCellByPosition(1,2):value = 245.
    
    
    Planilha:GetCellByPosition(0,3):string = "Soma".
    Planilha:GetCellByPosition(0,4):string = "Media".
    Planilha:GetCellByPosition(0,5):string = "Maximo".
    Planilha:GetCellByPosition(0,6):string = "Minimo".
    Planilha:GetCellByPosition(0,7):string = "Multiplica".
    
    Planilha:GetCellByPosition(1,3):Formula = "=sum(B1:B3)".
    Planilha:GetCellByPosition(1,4):Formula = "=average(B1:B3)".
    Planilha:GetCellByPosition(1,5):Formula = "=max(B1:B3)".
    Planilha:GetCellByPosition(1,6):Formula = "=min(B1:B3)".
    Planilha:GetCellByPosition(1,7):Formula = "=product(B1:B3)".
    
    /* Inserindo Bordas */
    Borda = Planilha:getPropertyValue("TopBorder").
    Borda:OuterLineWidth = 20. /* Espessura da Borda */
    
    Planilha:getCellRangeByPosition(0,0,1,2):setPropertyValue("TopBorder",Borda).
    Planilha:getCellRangeByPosition(0,0,1,2):setPropertyValue("BottomBorder",Borda).
    Planilha:getCellRangeByPosition(0,0,1,2):setPropertyValue("LeftBorder",Borda).
    Planilha:getCellRangeByPosition(0,0,1,2):setPropertyValue("RightBorder",Borda).
    
    
    /* Definindo formato numerico para coluna */
    Planilha:getColumns:getByIndex(1):setPropertyValue("NumberFormat",1).
    
    
    /* Mesclando Celulas */
    Planilha:GetCellByPosition(0,9):string = "Celula Mesclada".
    Planilha:GetCellRangeByPosition(0,9,1,9):Merge(yes).
    
    
    Planilha:GetCellByPosition(3,0):setPropertyValue("CellBackColor", {&black} ).
    Planilha:GetCellByPosition(3,1):setPropertyValue("CellBackColor", {&dark-blue} ).
    Planilha:GetCellByPosition(3,2):setPropertyValue("CellBackColor", {&dark-green} ).
    Planilha:GetCellByPosition(3,3):setPropertyValue("CellBackColor", {&dark-cyan} ).
    Planilha:GetCellByPosition(3,4):setPropertyValue("CellBackColor", {&dark-red} ).
    Planilha:GetCellByPosition(3,5):setPropertyValue("CellBackColor", {&dark-magenta} ).
    Planilha:GetCellByPosition(3,6):setPropertyValue("CellBackColor", {&dark-yellow} ).
    Planilha:GetCellByPosition(3,7):setPropertyValue("CellBackColor", {&dark-gray} ).
    Planilha:GetCellByPosition(3,8):setPropertyValue("CellBackColor", {&gray} ).
    Planilha:GetCellByPosition(3,9):setPropertyValue("CellBackColor", {&blue} ).
    Planilha:GetCellByPosition(3,10):setPropertyValue("CellBackColor", {&green} ).
    Planilha:GetCellByPosition(3,11):setPropertyValue("CellBackColor", {&cyan} ).
    Planilha:GetCellByPosition(3,12):setPropertyValue("CellBackColor", {&red} ).
    Planilha:GetCellByPosition(3,13):setPropertyValue("CellBackColor", {&magenta} ).
    Planilha:GetCellByPosition(3,14):setPropertyValue("CellBackColor", {&yellow} ).
    Planilha:GetCellByPosition(3,15):setPropertyValue("CellBackColor", {&white} ).
    Planilha:GetCellByPosition(3,16):setPropertyValue("CellBackColor", {&light-gray} ).
    Planilha:GetCellByPosition(3,17):setPropertyValue("CellBackColor", {&light-blue} ).
    Planilha:GetCellByPosition(3,18):setPropertyValue("CellBackColor", {&light-cyan} ).
    Planilha:GetCellByPosition(3,19):setPropertyValue("CellBackColor", {&light-green} ).
    Planilha:GetCellByPosition(3,20):setPropertyValue("CellBackColor", {&light-red} ).
    Planilha:GetCellByPosition(3,21):setPropertyValue("CellBackColor", {&light-magenta} ).
    Planilha:GetCellByPosition(3,22):setPropertyValue("CellBackColor", {&light-yellow} ).
    
    Planilha:GetCellByPosition(4,0):string = "black".
    Planilha:GetCellByPosition(4,0):setPropertyValue("CharColor", {&black} ).
    Planilha:GetCellByPosition(4,1):string = "dark-blue".
    Planilha:GetCellByPosition(4,1):setPropertyValue("CharColor", {&dark-blue} ).
    Planilha:GetCellByPosition(4,2):string = "dark-green".
    Planilha:GetCellByPosition(4,2):setPropertyValue("CharColor", {&dark-green} ).
    Planilha:GetCellByPosition(4,3):string = "dark-cyan".
    Planilha:GetCellByPosition(4,3):setPropertyValue("CharColor", {&dark-cyan} ).
    Planilha:GetCellByPosition(4,4):string = "dark-red".
    Planilha:GetCellByPosition(4,4):setPropertyValue("CharColor", {&dark-red} ).
    Planilha:GetCellByPosition(4,5):string = "dark-magenta".
    Planilha:GetCellByPosition(4,5):setPropertyValue("CharColor", {&dark-magenta} ).
    Planilha:GetCellByPosition(4,6):string = "dark-yellow".
    Planilha:GetCellByPosition(4,6):setPropertyValue("CharColor", {&dark-yellow} ).
    Planilha:GetCellByPosition(4,7):string = "dark-gray".
    Planilha:GetCellByPosition(4,7):setPropertyValue("CharColor", {&dark-gray} ).
    Planilha:GetCellByPosition(4,8):string = "gray".
    Planilha:GetCellByPosition(4,8):setPropertyValue("CharColor", {&gray} ).
    Planilha:GetCellByPosition(4,9):string = "blue".
    Planilha:GetCellByPosition(4,9):setPropertyValue("CharColor", {&blue} ).
    Planilha:GetCellByPosition(4,10):string = "green".
    Planilha:GetCellByPosition(4,10):setPropertyValue("CharColor", {&green} ).
    Planilha:GetCellByPosition(4,11):string = "cyan".
    Planilha:GetCellByPosition(4,11):setPropertyValue("CharColor", {&cyan} ).
    Planilha:GetCellByPosition(4,12):string = "red".
    Planilha:GetCellByPosition(4,12):setPropertyValue("CharColor", {&red} ).
    Planilha:GetCellByPosition(4,13):string = "magenta".
    Planilha:GetCellByPosition(4,13):setPropertyValue("CharColor", {&magenta} ).
    Planilha:GetCellByPosition(4,14):string = "yellow".
    Planilha:GetCellByPosition(4,14):setPropertyValue("CharColor", {&yellow} ).
    Planilha:GetCellByPosition(4,15):string = "white".
    Planilha:GetCellByPosition(4,15):setPropertyValue("CharColor", {&white} ).
    Planilha:GetCellByPosition(4,16):string = "light-gray".
    Planilha:GetCellByPosition(4,16):setPropertyValue("CharColor", {&light-gray} ).
    Planilha:GetCellByPosition(4,17):string = "light-blue".
    Planilha:GetCellByPosition(4,17):setPropertyValue("CharColor", {&light-blue} ).
    Planilha:GetCellByPosition(4,18):string = "light-cyan".
    Planilha:GetCellByPosition(4,18):setPropertyValue("CharColor", {&light-cyan} ).
    Planilha:GetCellByPosition(4,19):string = "light-green".
    Planilha:GetCellByPosition(4,19):setPropertyValue("CharColor", {&light-green} ).
    Planilha:GetCellByPosition(4,20):string = "light-red".
    Planilha:GetCellByPosition(4,20):setPropertyValue("CharColor", {&light-red} ).
    Planilha:GetCellByPosition(4,21):string = "light-magenta".
    Planilha:GetCellByPosition(4,21):setPropertyValue("CharColor", {&light-magenta} ).
    Planilha:GetCellByPosition(4,22):string = "light-yellow".
    Planilha:GetCellByPosition(4,22):setPropertyValue("CharColor", {&light-yellow} ).
    
    
    
    /* insere uma anotacao */
    Celula = Planilha:GetCellRangeByName("A1"):CellAddress. /* pega a celula */
    Planilha:getAnnotations:insertNew(celula,"AnotaþÒo").  /* inseri a anotacao */
    Planilha:getAnnotations:getByIndex(0):setIsVisible(yes). /* seta anotacao como visivel */
    
    
    /* formatacao de numeros */
    Planilha:GetCellRangeByName("A14"):String = "2 casas decimais com separador de milhar".
    Planilha:GetCellRangeByName("A15"):String = "2 casas decimais sem separador de milhar".
    Planilha:GetCellRangeByName("A16"):String = "inteiro sem separador de milhar".
    Planilha:GetCellRangeByName("A17"):String = "inteiro com separador de milhar".
    Planilha:GetCellRangeByName("A18"):String = "Moeda".
    Planilha:GetCellRangeByName("A19"):String = "Moeda (Negativo vermelho)".
    Planilha:GetCellRangeByName("A20"):String = "Percentual".
    Planilha:GetCellRangeByName("A21"):String = "Percentual".
    Planilha:GetCellRangeByName("A22"):String = "Data".
    Planilha:GetCellRangeByName("A23"):String = "Data".
    Planilha:GetCellRangeByName("A24"):String = "Data".
    Planilha:GetCellRangeByName("A25"):String = "Data".
    Planilha:GetCellRangeByName("A26"):String = "Data".
    Planilha:GetCellRangeByName("A27"):String = "Data".
    Planilha:GetCellRangeByName("A28"):String = "Data".
    Planilha:GetCellRangeByName("A29"):String = "Data".
    Planilha:GetCellRangeByName("A30"):String = "Data".
    Planilha:GetCellRangeByName("A31"):String = "Data".
    
    Planilha:GetCellRangeByName("B14"):Value = 123457.89.
    Planilha:GetCellRangeByName("B15"):Value = 123457.89.
    Planilha:GetCellRangeByName("B16"):Value = 123457.89.
    Planilha:GetCellRangeByName("B17"):Value = 123457.89.
    Planilha:GetCellRangeByName("B18"):Value = 123457.89.
    Planilha:GetCellRangeByName("B19"):Value = -123457.89.
    Planilha:GetCellRangeByName("B20"):Value = 123457.89.
    Planilha:GetCellRangeByName("B21"):Value = 123457.89.
    Planilha:GetCellRangeByName("B22"):Value = today.
    Planilha:GetCellRangeByName("B23"):Value = today.
    Planilha:GetCellRangeByName("B24"):Value = today.
    Planilha:GetCellRangeByName("B25"):Value = today.
    Planilha:GetCellRangeByName("B26"):Value = today.
    Planilha:GetCellRangeByName("B27"):Value = today.
    Planilha:GetCellRangeByName("B28"):Value = today.
    Planilha:GetCellRangeByName("B29"):Value = today.
    Planilha:GetCellRangeByName("B30"):Value = today.
    Planilha:GetCellRangeByName("B31"):Value = today.
    
    Planilha:GetCellRangeByName("B14"):setPropertyValue("NumberFormat",4). /* formata a celula */
    Planilha:GetCellRangeByName("B15"):setPropertyValue("NumberFormat",2). /* formata a celula */
    Planilha:GetCellRangeByName("B16"):setPropertyValue("NumberFormat",1). /* formata a celula */
    Planilha:GetCellRangeByName("B17"):setPropertyValue("NumberFormat",3). /* formata a celula */
    Planilha:GetCellRangeByName("B18"):setPropertyValue("NumberFormat",21). /* formata a celula */
    Planilha:GetCellRangeByName("B19"):setPropertyValue("NumberFormat",23). /* formata a celula */
    Planilha:GetCellRangeByName("B20"):setPropertyValue("NumberFormat",10). /* formata a celula */
    Planilha:GetCellRangeByName("B21"):setPropertyValue("NumberFormat",11). /* formata a celula */
    Planilha:GetCellRangeByName("B22"):setPropertyValue("NumberFormat",30). /* formata a celula */
    Planilha:GetCellRangeByName("B23"):setPropertyValue("NumberFormat",31). /* formata a celula */
    Planilha:GetCellRangeByName("B24"):setPropertyValue("NumberFormat",32). /* formata a celula */
    Planilha:GetCellRangeByName("B25"):setPropertyValue("NumberFormat",33). /* formata a celula */
    Planilha:GetCellRangeByName("B26"):setPropertyValue("NumberFormat",34). /* formata a celula */
    Planilha:GetCellRangeByName("B27"):setPropertyValue("NumberFormat",35). /* formata a celula */
    Planilha:GetCellRangeByName("B28"):setPropertyValue("NumberFormat",36). /* formata a celula */
    Planilha:GetCellRangeByName("B29"):setPropertyValue("NumberFormat",37). /* formata a celula */
    Planilha:GetCellRangeByName("B30"):setPropertyValue("NumberFormat",38). /* formata a celula */
    Planilha:GetCellRangeByName("B31"):setPropertyValue("NumberFormat",39). /* formata a celula */
    
    
    /* Ajuste automatico da largura das colunas */
    Planilha:getColumns:OptimalWidth = yes.
    
    
    /* Ocultando uma coluna */
    /* PS: este comando deve ser executado depois do ajuste automatico de largura */
    Planilha:GetCellByPosition(2,0):string = "Coluna escondida".
    Planilha:getColumns:getByIndex(2):isVisible = no.
    
    
    /* Salva documento em disco */
    if Documento:isModified = yes and Documento:isReadOnly = no
    then do:
      if Documento:hasLocation then
      Documento:storeAsUrl().
      else
      Documento:storeAsUrl(vArq,cc).
    end.
    
    /*
    system-dialog printer-setup.
    
    /* Imprimi documento */
    Documento:SetPropertyValue("Print", SESSION:PRINTER-NAME).
    Documento:SetPropertyValue("CopyCount", 3). /* N·mero de c¾pias - Comando nÒo funciona */
    Documento:SetPropertyValue("Collate",FALSE).
    Documento:SetPropertyValue("Wait", TRUE). /*Caso der erro na impressÒo retorna*/
    Documento:PRINT(CC).
    
    /* Finaliza BrOffice */
    pause(3). /* pause para concluir a impressÒo e salvar antes de finalizar */
    Documento:dispose().
    Desktop:terminate().
    */
    
    release object Celula.
    release object Borda.
    release object Rodape.
    release object Cabecalho.
    release object Padrao.
    release object Documento.
    release object Planilha.
    release object Desktop.
    release object BrOffice.
    
    
    rhemati curtiu isso.
  4. HumbertoOrtiz

    HumbertoOrtiz Membro Participativo

    Muito obrigado.
    Com os exemplos eu consegui fazer o meu relatório.
  5. danichi

    danichi Sem Pontuação

    Olá boa noite!

    por acaso você já usou o GROUP no libre office ? estou apanhando pra fazer o agrupamento das células, linhas ou colunas.

    Obrigada,
    Daniela.
  6. rhemati

    rhemati Membro Participativo

    Top. Testei. Funciona!
    jdchaves curtiu isso.

Compartilhe esta Página