Skip to main content
Announcements
Have questions about Qlik Connect? Join us live on April 10th, at 11 AM ET: SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
girino777
Creator III
Creator III

Alterar código para ficar automático

Bom Dia.!

Utilizo o seguinte código abaixo que peguei aqui no fórum para carregar todas as abas de uma planilha excel.

O problema é que sempre que incluo uma nova aba tenho que alterar o código no FOR.

Alguém teria alguma solução para incrementar o código abaixo deixando automático quando eu incluir alguma aba?

Obs. Eu utilizei outra opção com SQL tables, porém não me atendeu da forma que eu queria.

FOR i = 1 to 3

Arquivo:

LOAD A,

     B,

     C,

     D,

     E

FROM

C:\Users\eric.tiburcio.CONVERGENCE.000\Desktop\Abas.xlsx

(ooxml, embedded labels,Table is Plan$(i));

NEXT

Muito Obrigado.

Renato

1 Solution

Accepted Solutions
girino777
Creator III
Creator III
Author

Pessoal

Bom Dia.!

Após várias pesquisas e consultas consegui adaptar o código abaixo acrescentando os campos em vermelho e funcionou.

Estou compartilhando para caso alguém precise também.

FOR EACH file in FileList('C:\ARQUIVO.xlsx');

ODBC CONNECT32 TO [Excel Files;DBQ=$(file)];

Temp:

SQLtables;

DISCONNECT;

FOR i = 0 to NoOfRows('Temp')-1

LET sheetName = purgeChar(purgeChar(peek('TABLE_NAME', i, 'Temp'), chr(39)), chr(36));

    if Right('$(sheetName)',8) <> 'Database' then

NOME_TABELA:

Load  

A,B,C,D

FROM 'C:\ARQUIVO.xlsx'

(ooxml, embedded labels, table is  [$(sheetName)]);

STORE  NOME_TABELA INTO 'C:\NOME_ARQUIVO.QVD' (QVD);

  end if;

NEXT i

  DROP NOME_TABELA;

Next

View solution in original post

3 Replies
Thiago_Justen_

Renato,

Veja se o código apresentado nesse post também te atende:

loading all sheets data from excel | Qlik Community

Abs e Sucesso!

Thiago Justen Teixeira Gonçalves
Farol BI
WhatsApp: 24 98152-1675
Skype: justen.thiago
Ricardo_Gerhard
Employee
Employee

Boa tarde Renato,

  Esse é o código que atenderá sua demanda:

Load data from multiple worksheets in multiple Excel workbooks

Ricardo Gerhard
OEM Solution Architect
LATAM
girino777
Creator III
Creator III
Author

Pessoal

Bom Dia.!

Após várias pesquisas e consultas consegui adaptar o código abaixo acrescentando os campos em vermelho e funcionou.

Estou compartilhando para caso alguém precise também.

FOR EACH file in FileList('C:\ARQUIVO.xlsx');

ODBC CONNECT32 TO [Excel Files;DBQ=$(file)];

Temp:

SQLtables;

DISCONNECT;

FOR i = 0 to NoOfRows('Temp')-1

LET sheetName = purgeChar(purgeChar(peek('TABLE_NAME', i, 'Temp'), chr(39)), chr(36));

    if Right('$(sheetName)',8) <> 'Database' then

NOME_TABELA:

Load  

A,B,C,D

FROM 'C:\ARQUIVO.xlsx'

(ooxml, embedded labels, table is  [$(sheetName)]);

STORE  NOME_TABELA INTO 'C:\NOME_ARQUIVO.QVD' (QVD);

  end if;

NEXT i

  DROP NOME_TABELA;

Next