14 Replies Latest reply: Dec 15, 2015 7:30 AM by Peterjohn Griffiths RSS

    Macro to export straight table to csv after reload on server.

    Peterjohn Griffiths

      I have been trying to do this for some time, but I can't seem to find an answer.
      I need to export a straight table to a CSV file.
      Below is a test setup I am using to simpify the process while investigating the problem.

       

      I first create some test data in a load script as follows;

      //Example Data
      QUALIFY *;
      Example_Data:
      LOAD * Inline 
      [Asset,User,OS
      UK01,sparnaby,WinVista
      UK02,tbrown,Win7
      UK03,mrichards,Win8
      ];
      
      
      
      
      

       

      To test the output folder has access, I output this table using the Store command as follows;

      STORE Example_Data into c:\TestCSV\Table_Example_Data.csv (txt);
      
      
      
      
      

       

      I then create a straight table to output the example data and add a count field with a total. I call this stright table "Table_Data".

       

      I create a Macro to output the straight table as follows;

      Sub ExportTest
       Set obj = ActiveDocument.GetSheetObject("Table_Data")
       obj.ExportBiff "c:\TestCSV\Data.csv"
      End Sub
      
      
      
      
      

       

      In the Edit Module section this macro is in, I set the following fileds;
      Requested Module Security: System Access
      Current Local Security: Allow System Access

       

      In the main Qlikview document I also go into Settings->Document Properties->[Triggers] tab.
      I select "OnPostReload" and click [Add Action(s)] button.
      I add "Run Macro" and set the Macro Name to "ExportTest".

       

      I then setup security Settings on the Qlikview Management Server.
      [System] tab->[Setup] subtab->Select Server from the list.
      [Security] tab on the server.
      [Tick] Allow macro execution on server
      [Tick] Allow unsafe macro execution on server
      Clicked [Apply]

       

      I then setup the output folder c:\TestCSV and added full permissions for the AD accounts the qlikview services run on.

       

      I open and run the report fine from the qlikview client and c:\TestCSV folder contains both the output files
      Data.csv
      Table_Example_Data.csv

       

      The problems is if I create a task on the Qlikview Management Server, it only outputs the one file.
      Table_Example_Data.csv

       

      Anyone got any idea how to do this?.


      Many thanks in advance.

       

      EDIT - I have added the example QVW file.