Qlik Community

QlikView Scripting

Discussion Board for collaboration on QlikView Scripting.

ramusubramani
New Contributor II

File Extension

Hi qlikview


I am loading some excel files in qlikivew. user  giving the files format as sometime .XLS or .XLSX. Is it possible in QV code to make dynamic loading without changing the script every time


regards

Ramu

Tags (1)
3 Replies
crusader_
Valued Contributor

Re: File Extension

Hi,

Yes, use mask *.

LOAD Field1

     ,  Field2

FROM YourFile.*

Please be aware that all file extensions will be considered to load for file with the same name.

HTH

Andrei

MVP
MVP

Re: File Extension

For a single known Excel file:

You could create two load statement. Set ErrorMode = 0, then perform the first load (using xls/biff). This will eaither succeed or fail silently. Check the error status or the loaded table to determine if it was successful. If it failed,then load the file using xlsx/ooxml.

Logic will get you from a to b. Imagination will take you everywhere. - A Einstein
MVP
MVP

Re: File Extension

Or you could use a structure like:

For Each vExt in 'xls', 'xlsx'

  For Each vFile in FileList('*.$(vExt)')

    If vExt = 'xls' Then

    Table1:

    LOAD ....

    FROM [$(vFile)]

    (biff, ....)

  Else

    Table1:

    LOAD ....

    FROM [$(vFile)]

    (ooxml, ....)

    End If

Next

Next

Logic will get you from a to b. Imagination will take you everywhere. - A Einstein
Community Browser