Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
rido1421
Creator III
Creator III

Connecting to multiple excel sheet names

Hi There

I have an issue loading data from excel.

The excel document will be generated monthly , and the file name of the document will be named after the month.

Sales20160131.xlsx

I know I can deal with each file by loading * but how would I deal with the sheet names because that will change on each document as well?

Your assistance is appreciated.

LOAD

Sales_Value,

Product

FROM
 
$(vPath)\Sales_*.xlsx
(
ooxml, embedded labels, table is Sales_20160131);

Regards,

1 Solution
7 Replies
jonathandienst
Partner - Champion III
Partner - Champion III

Load like this:

For Each vFile in FileList('<path>\Sales*.xlsx')

  Let vFilename = SubField(SubField(vFile, '\', -1), '.', 1);

  Let vSheet = 'Sales_' & TextBetween(vFilename, 'Sales', '.xlsx')

  Data:

  LOAD

    Sales_Value,

    Product,

    BaseFileName() as FileSource,

    Date(Date#(TextBetween(BaseFileName(), 'Sales', '.xlsx'), 'yyyyMMdd')) as FileDate

  FROM

    $(vPath)\Sales_*.xlsx

    (ooxml, embedded labels, table is $(vSheet));

Next

(Replace <path> in the FileList statement with the correct path to the source files)

Logic will get you from a to b. Imagination will take you everywhere. - A Einstein
Anonymous
Not applicable

Hi,

Check this link:

Load all Excel files and all sheets in a folder

Hope it helps!!

rido1421
Creator III
Creator III
Author

Thank you this is very simple , and seems to be effective.

rido1421
Creator III
Creator III
Author

Hi Jonathan

is the correct syntax "FileBaseName() "

For some reason when I do it this way it reloads but doesn't return anything in the table.