<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Loading xls or xlsx in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/Loading-xls-or-xlsx/m-p/264907#M707933</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'm trying to figure out what file extension a file has before load statement. The file is provided by users and sometimes they use .xls and other times .xlsx, so I need to alter loading depending on extension.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Right now the closest to a good solution is two load scripts and supress errors with&lt;/P&gt;&lt;PRE __default_attr="plain" __jive_macro_name="code" class="jive_text_macro jive_macro_code"&gt;&lt;P&gt;set ErrorMode=0;&lt;/P&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;But I would like a more flexible solution, perhaps an IF-statement? Check filelist?&lt;/P&gt;&lt;P&gt;Filename are always the same and so is content.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;regards&lt;/P&gt;&lt;P&gt;thomas&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 11 Jan 2012 09:18:52 GMT</pubDate>
    <dc:creator />
    <dc:date>2012-01-11T09:18:52Z</dc:date>
    <item>
      <title>Loading xls or xlsx</title>
      <link>https://community.qlik.com/t5/QlikView/Loading-xls-or-xlsx/m-p/264907#M707933</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'm trying to figure out what file extension a file has before load statement. The file is provided by users and sometimes they use .xls and other times .xlsx, so I need to alter loading depending on extension.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Right now the closest to a good solution is two load scripts and supress errors with&lt;/P&gt;&lt;PRE __default_attr="plain" __jive_macro_name="code" class="jive_text_macro jive_macro_code"&gt;&lt;P&gt;set ErrorMode=0;&lt;/P&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;But I would like a more flexible solution, perhaps an IF-statement? Check filelist?&lt;/P&gt;&lt;P&gt;Filename are always the same and so is content.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;regards&lt;/P&gt;&lt;P&gt;thomas&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 11 Jan 2012 09:18:52 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Loading-xls-or-xlsx/m-p/264907#M707933</guid>
      <dc:creator />
      <dc:date>2012-01-11T09:18:52Z</dc:date>
    </item>
    <item>
      <title>Re: Loading xls or xlsx</title>
      <link>https://community.qlik.com/t5/QlikView/Loading-xls-or-xlsx/m-p/264908#M707934</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Thomas,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Based on &lt;A _jive_internal="true" href="https://community.qlik.com/thread/17774"&gt;this code&lt;/A&gt;, I'd do something like the following&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE __default_attr="plain" __jive_macro_name="code" class="jive_text_macro jive_macro_code"&gt;&lt;P&gt;SET vFileIsBiff = '(biff, embedded labels, table is [Sheet1$])';&lt;/P&gt;&lt;P&gt;SET vFileIsOOXML = '(ooxml, embedded labels, table is Sheet1);';&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Sub DoDir (Root) &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; For Each vExt In 'xls', 'xlsx' // filetype to search for in current directory &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; For Each vFile In FileList (Root &amp;amp; '\Test.' &amp;amp; vExt) &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; LET vFileType = If('$(vExt)' = 'xls', '$(vFileIsBiff)', '$(vFileIsOOXML)');&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; File: &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; LOAD * &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; FROM [$(vFile)] &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; $(vFileType); &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Next vFile &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Next vExt&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; For Each vDir In DirList (Root &amp;amp; '\*') // search in subdirectories &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Call DoDir (vDir) &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Next vDir &lt;/P&gt;&lt;P&gt;End Sub &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Call DoDir ('C:\Temp'); // Starting point &lt;/P&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So depending on the extension you load each format. The code still seems to me too complex, and some directory recursion might not be needed, or even just an If() will do, since you only want to load one file and there is no need to use a For loop...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope that helps, anyway.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Miguel&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 11 Jan 2012 12:13:41 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Loading-xls-or-xlsx/m-p/264908#M707934</guid>
      <dc:creator>Miguel_Angel_Baeyens</dc:creator>
      <dc:date>2012-01-11T12:13:41Z</dc:date>
    </item>
    <item>
      <title>Loading xls or xlsx</title>
      <link>https://community.qlik.com/t5/QlikView/Loading-xls-or-xlsx/m-p/264909#M707935</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt; Thomas,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You could create a custom function for use in the script.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;We must remember that a file could exist as BOTH an .xls and an .xlsx in the same folder and that could cause problems!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In the script you could create a variable that will hold the extension name for the name of the file (without extension) passed to the custom function like this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;LET vExtn = WhichExtn('C:\mypath\filename');&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;which you could test for a valid value being returned by the function and if OK then use the (substitution) variable in the load statement.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The function would look like this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Function WhichExtn (fileName)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; WhichExtn = ""&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; set fso = CreateObject("Scripting.FileSystemObject")&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; on error resume next&lt;BR /&gt;&amp;nbsp; &lt;BR /&gt;&amp;nbsp; set fileExists = fso.GetFile(fileName &amp;amp; ".xls")&lt;/P&gt;&lt;P&gt;&amp;nbsp; if err = 0 then&amp;nbsp; ' file exists as xls&lt;BR /&gt;&amp;nbsp;&amp;nbsp; WhichExtn = WhichExtn &amp;amp; "xls"&lt;BR /&gt;&amp;nbsp; end if&lt;BR /&gt;&amp;nbsp; &lt;BR /&gt;&amp;nbsp; err.clear&lt;BR /&gt;&amp;nbsp; &lt;BR /&gt;&amp;nbsp; set fileExists = fso.GetFile(fileName &amp;amp; ".xlsx"&lt;/P&gt;&lt;P&gt;&amp;nbsp; if err = 0 then&amp;nbsp; ' file exists as xlsx&lt;BR /&gt;&amp;nbsp;&amp;nbsp; WhichExtn = WhichExtn &amp;amp; "xlsx"&lt;BR /&gt;&amp;nbsp; end if&lt;BR /&gt;&amp;nbsp; &lt;BR /&gt;&amp;nbsp; on error goto 0&lt;BR /&gt; &lt;BR /&gt;&amp;nbsp; set fso = Nothing&amp;nbsp; ' release memory&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;End Function &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This will trap the file not existing with either extension (vExtn = "") or if the file exists in both formats (vExtn = "xlsxlsx"&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope this helps.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Gordon&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 11 Jan 2012 12:26:44 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Loading-xls-or-xlsx/m-p/264909#M707935</guid>
      <dc:creator />
      <dc:date>2012-01-11T12:26:44Z</dc:date>
    </item>
    <item>
      <title>Loading xls or xlsx</title>
      <link>https://community.qlik.com/t5/QlikView/Loading-xls-or-xlsx/m-p/264910#M707936</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt; ...just noticed a typo&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;set fileExists = fso.GetFile(fileName &amp;amp; ".xlsx"&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;should read as&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;set fileExists = fso.GetFile(fileName &amp;amp; ".xlsx")&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 11 Jan 2012 12:29:29 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Loading-xls-or-xlsx/m-p/264910#M707936</guid>
      <dc:creator />
      <dc:date>2012-01-11T12:29:29Z</dc:date>
    </item>
    <item>
      <title>Loading xls or xlsx</title>
      <link>https://community.qlik.com/t5/QlikView/Loading-xls-or-xlsx/m-p/264911#M707937</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks guys!&lt;/P&gt;&lt;P&gt;Not working out of the box but I have a (two) starting points.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 11 Jan 2012 13:12:14 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Loading-xls-or-xlsx/m-p/264911#M707937</guid>
      <dc:creator />
      <dc:date>2012-01-11T13:12:14Z</dc:date>
    </item>
  </channel>
</rss>

