3 Replies Latest reply: Jun 6, 2016 8:45 AM by Jonathan Dienst RSS

    File Extension

    Ramu Subramaniyan

      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

        • Re: File Extension
          Andrei Kaliahin

          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

          • Re: File Extension
            Jonathan Dienst

            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.

              • Re: File Extension
                Jonathan Dienst

                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