ALTERNATICA CRIAR DOCUMENTOS DO WORD

181 views
Skip to first unread message

ejs...@gmail.com

unread,
Sep 30, 2022, 4:34:39 PM9/30/22
to Progress - 4GL
Boa tarde.

Preciso encontrar uma alternativa para criar relatórios bem elaborados sem a utilização do componente Word (Office) em específicos?

Tentei com o LibreOffice porém a interface que a Totvs criou não é rica em funcionalidades, por exemplo não suporta tabelas.

Robert

unread,
Oct 1, 2022, 9:06:51 AM10/1/22
to Progress - 4GL
O documento que você precisa criar terá sempre o mesmo layout?
Se sim, poderia fazer algo com arquivos RTF. Da mesma forma que a Totvs faz para a geração da DANFE.

Cria um arquivo RTF (no word) e nos campos onde precisa colocar uma informação, coloca $nome (por exemplo).
E no teu código, importa o arquivo padrão (rtf) para uma variável e faz a substituição dos campos pelos dados desejados.
Comando REPLACE ... dá uma olhada no help do progress para mais detalhes.

ejs...@gmail.com

unread,
Oct 3, 2022, 7:05:33 PM10/3/22
to Progress - 4GL
Boa noite.
@Robert, no meu caso, irei utilizar uma tabela e a quantidade de linhas poderá variar em função da quantidade de dados então preciso caminhar por uma temp-table e criar uma nova row na tabela para apresentar os dados da temp-table. No word consigo adicionar novas linhas na tabela mas não encontrei isto no liibreoffice.

Message has been deleted
Message has been deleted

Cleverson

unread,
Oct 14, 2022, 9:16:10 AM10/14/22
to Progress - 4GL
Boa tarde, uma alternativa seria o uso de BrOffice 

Você cria um modelo, e cria marcadores nos pontos que você precisa alterar textos e onde deseja criar a tabela com os dados.
é bem semelhante ao método utilizado no Word com indicadores....

segue um exemplo abaixo.



DEFINE VARIABLE hSM       AS COM-HANDLE NO-UNDO.
DEFINE VARIABLE hDesktop  AS COM-HANDLE NO-UNDO.
DEFINE VARIABLE hDocument AS COM-HANDLE NO-UNDO.
DEFINE VARIABLE hText     AS COM-HANDLE NO-UNDO.
DEFINE VARIABLE hCursor   AS COM-HANDLE NO-UNDO.
DEFINE VARIABLE hCursor2   AS COM-HANDLE NO-UNDO.

DEFINE VARIABLE hTable    AS COM-HANDLE NO-UNDO.
DEFINE VARIABLE hRows     AS COM-HANDLE NO-UNDO.
DEFINE VARIABLE hRow      AS COM-HANDLE NO-UNDO.

DEFINE VARIABLE Args1     AS RAW        NO-UNDO.
DEFINE VARIABLE Args2     AS RAW        NO-UNDO.


CREATE "com.sun.star.ServiceManager" hSM.
       hDesktop = hSM:createInstance("com.sun.star.frame.Desktop").
       hDocument = hDesktop:loadComponentFromURL("file:///c:/seuModelo.ott","_blank",0,Args1).
       
       hText = hDocument:getText().
       hCursor = hText:createTextCursor().

       hDocument:Bookmarks:getByName("ind_Nome"):Anchor:setString("JOAO MARIA").

       // INCERE TABELA
       hDocument:currentController:viewCursor:gotoRange(hDocument:BookMarks:getByName("ind_Tabela"):Anchor,FALSE).
       hCursor = hDocument:currentController:getviewCursor().
       hCursor:gotoStartOfLine(FALSE).

       // tabela com 3 linhas e 4 colunas incluindo a linha de cabecalhos
       DEF VAR i-linhas  AS INT NO-UNDO INIT 3.
       DEF VAR i-colunas AS INT NO-UNDO INIT 4.

       hTable = hDocument:createInstance("com.sun.star.text.TextTable").
       /* Cria Tabela */
       hTable:initialize(i-linhas,i-colunas).
       
       /* Insere Tabela */
       hText:insertTextContent(hCursor, hTable, false).

       hTable:HoriOrient = 0.

       /* Alinhamento Tabela */
       hTable:LeftMargin  = 0.
       hTable:RightMargin = 0.
     
       /* Seleciona Primeira Linha */
       hRows = hTable:getrows().
       hRow  = hRows:getByIndex(0).
     
       /* Seta Novo Cursor */
       hCursor2 = hTable:createCursorByCellName("A1").
     
       /* Cria Cabecalho na primeira Linha */
       hTable:getCellByName("A1"):setString("PRODUTO").
       hTable:getCellByName("B1"):setString("EMBAL").
       hTable:getCellByName("C1"):setString("QTDE").
       hTable:getCellByName("D1"):setString("VALOR.(R$)").

      // MESCLAR CELULAS A2 ATE C2
      // hCursor2:gotoCellByName("A2", False).
      // hCursor2:goRight(2, True). /* Move 2 celulas para direita */
      // hCursor2:mergeRange().
       DEF VAR I-CONT AS INT INIT 2.
       DO I-CONT = 2 TO 3:
           /* Insere Textos Tabela  ******************************/
        hTable:getCellByName("A" + STRING(I-CONT)):setstring("A" + STRING(I-CONT)).
        hTable:getCellByName("B" + STRING(I-CONT)):setstring("KG").
        hTable:getCellByName("C" + STRING(I-CONT)):setValue(STRING(I-CONT)).
        hTable:getCellByName("D" + STRING(I-CONT)):setValue(STRING(I-CONT * 2)).
       END.
     
       hDocument:storeAsUrl("file:///c:/Relatorio.odt",Args2).

       RELEASE OBJECT hSM.
       RELEASE OBJECT hDesktop.
       RELEASE OBJECT hDocument.
       RELEASE OBJECT hText.
       RELEASE OBJECT hCursor.
       RELEASE OBJECT hTable.
       RELEASE OBJECT hCursor2.
       RELEASE OBJECT hRows.
       RELEASE OBJECT hRow.

Reply all
Reply to author
Forward
0 new messages