Gerar Gráfico no Excel

Discussão em 'Progress 4GL' iniciado por eder.luca2012, Julho 14, 2012.

  1. eder.luca2012

    eder.luca2012 Membro Participativo

    Pessoal estou com uma dúvida hoje eu consigo gerar tabelas em excel utilizando a linguagem progress porém eu gostaria de gerar gráficos, porém quando eu tento somente gerar o planilha da certo, porém quando eu começo executar os comandos para gerar gráficos nem aparece minha planilha alguem poderia me ajudar? abaixo segue o meu código.

    /*
    KSV Editor
    Copyright: (C) 2000-2006 Serguey Klimoff (bulklodd)
    Filename: DOCUMENTS AND SETTINGS\CPD-EDER\DESKTOP\GERA GRAFICOS.P
    Comment: <comment>
    Parameters:
    Uses:
    Used by:
    Created: 14.07.2012 11:49 CPD-EDER
    Modified: 14.07.2012 13:17 CPD-EDER <comment>
    */

    def var linha AS INTEGER NO-UNDO.
    DEF VAR coluna AS INTEGER NO-UNDO.
    def var c-range AS CHAR NO-UNDO.
    def var excelappl AS COM-HANDLE NO-UNDO.
    DEF VAR janeiro AS INTEGER.
    DEF VAR fevereiro AS INTEGER.
    DEF VAR marco AS INTEGER.
    DEF VAR abril AS INTEGER.
    DEF VAR maio AS INTEGER.
    DEF VAR junho AS INTEGER.
    DEF VAR julho AS INTEGER.
    DEF VAR agosto AS INTEGER.
    DEF VAR setembro AS INTEGER.
    DEF VAR outubro AS INTEGER.
    DEF VAR novembro AS INTEGER.
    DEF VAR dezembro AS INTEGER.

    ASSIGN janeiro = 0.
    ASSIGN fevereiro = 0.
    ASSIGN marco = 0.
    ASSIGN abril = 0.
    ASSIGN maio = 0.
    ASSIGN junho = 0.
    ASSIGN julho = 0.
    ASSIGN agosto = 0.
    ASSIGN setembro = 0.
    ASSIGN outubro = 0.
    ASSIGN novembro = 0.
    ASSIGN dezembro = 0.


    CREATE "excel.application" excelappl.

    excelappl:visible = FALSE .
    excelappl:workbooks:add("c:\temp\teste.xltx").
    excelappl:worksheets:item(1):select.

    ASSIGN linha = 2.

    FOR EACH usuario WHERE usuario.dt-exclusao-plano = ?
    AND YEAR(usuario.dt-inclusao-plano) = 2012 NO-LOCK BREAK BY usuario.dt-inclusao-plano.

    IF (MONTH(usuario.dt-inclusao-plano) = 01) THEN DO:
    ASSIGN janeiro = janeiro + 1.
    END.

    IF (MONTH(usuario.dt-inclusao-plano) = 02) THEN DO:
    ASSIGN fevereiro = fevereiro + 1.
    END.

    IF (MONTH(usuario.dt-inclusao-plano) = 03) THEN DO:
    ASSIGN marco = marco + 1.
    END.

    IF (MONTH(usuario.dt-inclusao-plano) = 04) THEN DO:
    ASSIGN abril = abril + 1.
    END.

    IF (MONTH(usuario.dt-inclusao-plano) = 05) THEN DO:
    ASSIGN maio = maio + 1.
    END.

    IF (MONTH(usuario.dt-inclusao-plano) = 06) THEN DO:
    ASSIGN junho = junho + 1.
    END.

    IF (MONTH(usuario.dt-inclusao-plano) = 07) THEN DO:
    ASSIGN julho = julho + 1.
    END.

    IF (MONTH(usuario.dt-inclusao-plano) = 08) THEN DO:

    END.

    IF (MONTH(usuario.dt-inclusao-plano) = 09) THEN DO:

    END.

    IF (MONTH(usuario.dt-inclusao-plano) = 10) THEN DO:

    END.

    IF (MONTH(usuario.dt-inclusao-plano) = 11) THEN DO:

    END.

    IF (MONTH(usuario.dt-inclusao-plano) = 12) THEN DO:

    END.
    END.

    excelappl:range("B" + string(linha, "99999999999999")):value = janeiro.
    excelappl:range("C" + string(linha, "99999999999999")):value = fevereiro.
    excelappl:range("D" + string(linha, "99999999999999")):value = marco.
    excelappl:range("E" + string(linha, "99999999999999")):value = abril.
    excelappl:range("F" + string(linha, "99999999999999")):value = maio.
    excelappl:range("G" + string(linha, "99999999999999")):value = junho.
    excelappl:range("H" + string(linha, "99999999999999")):value = julho.
    excelappl:range("I" + string(linha, "99999999999999")):value = agosto.
    excelappl:range("J" + string(linha, "99999999999999")):value = setembro.
    excelappl:range("K" + string(linha, "99999999999999")):value = outubro.
    excelappl:range("L" + string(linha, "99999999999999")):value = novembro.
    excelappl:range("M" + string(linha, "99999999999999")):value = dezembro.

    excelappl:Range("A1:M2"):Select.
    excelappl = excelappl:Application:ActiveSheet:Shapes:AddChart(70).
    excelappl:Application:ActiveSheet:ChartObjects("Gr fico 1"):Activate.
    excelappl:Application:ActiveChart:ApplyLayout (6).
    excelappl:Application:ActiveChart:ChartTitle:Select.
    excelappl:Application:ActiveChart:ChartTitle:Text = "".

    excelappl:visible = TRUE .
  2. eduardo.leite

    eduardo.leite Equipe de Suporte Moderador Equipe de Suporte

    Caro colega,

    Testa ai este codigo modificado:

    Código:
    
    def var linha       as integer          no-undo.
    def var coluna      as integer          no-undo.
    def var c-range     as char             no-undo.
    def var ExcelAppl   as com-handle       no-undo.
    def var ActiveSheet as com-handle       no-undo.
    
    def var janeiro     as integer.
    def var fevereiro   as integer.
    def var marco       as integer.
    def var abril       as integer.
    def var maio        as integer.
    def var junho       as integer.
    def var julho       as integer.
    def var agosto      as integer.
    def var setembro    as integer.
    def var outubro     as integer.
    def var novembro    as integer.
    def var dezembro    as integer.
    
    assign  janeiro     = /*0*/ random(100,150)
            fevereiro   = /*0*/ random(100,150)
            marco       = /*0*/ random(100,150)
            abril       = /*0*/ random(100,150)
            maio        = /*0*/ random(100,150)
            junho       = /*0*/ random(100,150)
            julho       = /*0*/ random(100,150)
            agosto      = /*0*/ random(100,150)
            setembro    = /*0*/ random(100,150)
            outubro     = /*0*/ random(100,150)
            novembro    = /*0*/ random(100,150)
            dezembro    = /*0*/ random(100,150).
    
    create "excel.application" ExcelAppl.
    
    ExcelAppl:DisplayAlerts  = no /*** Não mostrar mensagens de error ***/.
    ExcelAppl:visible        = no /*** Não mostrar a planilha na tela ***/.
    ExcelAppl:ScreenUpdating = no /*** Não efetuar display na tela    ***/.
    
    excelappl:workbooks:add(). 
    
    assign linha = 1.
    
    ExcelAppl:range("a" + string(linha + 1)):value = "Quantidade".
    ExcelAppl:range("b" + string(linha)):value = "Janeiro".
    ExcelAppl:range("c" + string(linha)):value = "Fevereiro".
    ExcelAppl:range("d" + string(linha)):value = "Marco".
    ExcelAppl:range("e" + string(linha)):value = "Abril".
    ExcelAppl:range("f" + string(linha)):value = "Maio".
    ExcelAppl:range("g" + string(linha)):value = "Junho".
    ExcelAppl:range("h" + string(linha)):value = "Julho".
    ExcelAppl:range("i" + string(linha)):value = "Agosto".
    ExcelAppl:range("j" + string(linha)):value = "Setembro".
    ExcelAppl:range("k" + string(linha)):value = "Outubro".
    ExcelAppl:range("l" + string(linha)):value = "Novembro".
    ExcelAppl:range("m" + string(linha)):value = "Dezembro".
    
    assign linha = 2.
    
    /* for each usuario                                        */
    /*    where usuario.dt-exclusao-plano       = ?            */
    /*      and year(usuario.dt-inclusao-plano) = 2012 no-lock */
    /*       by usuario.dt-inclusao-plano.                     */
    /*                                                         */
    /*     case (month(usuario.dt-inclusao-plano):             */
    /*                                                         */
    /*         when 01 then assign janeiro   = janeiro   + 1.  */
    /*         when 02 then assign fevereiro = fevereiro + 1.  */
    /*         when 03 then assign marco     = marco     + 1.  */
    /*         when 04 then assign abril     = abril     + 1.  */
    /*         when 05 then assign maio      = maio      + 1.  */
    /*         when 06 then assign junho     = junho     + 1.  */
    /*         when 07 then assign julho     = julho     + 1.  */
    /*         when 08 then assign agosto    = agosto    + 1.  */
    /*         when 09 then assign setembro  = setembro  + 1.  */
    /*         when 10 then assign outubro   = outubro   + 1.  */
    /*         when 11 then assign novembro  = novembro  + 1.  */
    /*         when 12 then assign dezembro  = dezembro  + 1.  */
    /*                                                         */
    /*     end case.                                           */
    /*                                                         */
    /* end.                                                    */
    
    ExcelAppl:range("b" + string(linha)):value = janeiro.
    ExcelAppl:range("c" + string(linha)):value = fevereiro.
    ExcelAppl:range("d" + string(linha)):value = marco.
    ExcelAppl:range("e" + string(linha)):value = abril.
    ExcelAppl:range("f" + string(linha)):value = maio.
    ExcelAppl:range("g" + string(linha)):value = junho.
    ExcelAppl:range("h" + string(linha)):value = julho.
    ExcelAppl:range("i" + string(linha)):value = agosto.
    ExcelAppl:range("j" + string(linha)):value = setembro.
    ExcelAppl:range("k" + string(linha)):value = outubro.
    ExcelAppl:range("l" + string(linha)):value = novembro.
    ExcelAppl:range("m" + string(linha)):value = dezembro.
    
    ExcelAppl:range("a1:m2"):ColumnWidth = 12.
    
    ExcelAppl:range("a1:m2"):select.
    
    ExcelAppl:ActiveSheet:Shapes:AddChart:select.
    ExcelAppl:ActiveChart:ChartType = 70.
    ExcelAppl:ActiveChart:ApplyLayout(6).
    ExcelAppl:ActiveChart:ChartTitle:text = "".
    
    ExcelAppl:range("a4"):select.
    
    ExcelAppl:DisplayAlerts  = yes /*** Não mostrar mensagens de error ***/.
    ExcelAppl:visible        = yes /*** Não mostrar a planilha na tela ***/.
    ExcelAppl:ScreenUpdating = yes /*** Não efetuar display na tela    ***/.
    
    
  3. eder.luca2012

    eder.luca2012 Membro Participativo

    Eduardo funcionou perfeito obrigado agora tenho base para poder aprimorar agora tira uma última dúvida onde eu posso pesquisar para saber como definir os tipos de gráficos a serem gerados?
  4. eduardo.leite

    eduardo.leite Equipe de Suporte Moderador Equipe de Suporte

    Normalmente, eu abro um EXCEL habilito a Macro e faço os gráficos, depois paro a execução da macro e mando editar (abrindo o códibo VB) lá dentro tem os parãmetros e valores destes, clique com o botão direito em cima do valor e pede informação rapida e ele mostrará o valor que deverá ser informado no progress.

    Arquivos Anexados:

  5. eder.luca2012

    eder.luca2012 Membro Participativo

    Eduardo existe algum comando para renomear às abas do excel?
  6. jdchaves

    jdchaves Membro Participativo

    Código:
    excelappl:worksheets:ITEM(1):SELECT.
    excelappl:worksheets:ITEM(1):NAME = "NOME AQUI".
    

Compartilhe esta Página