STEP 1: Get the Sheet ID of the QlikView document. You can also modify the sheet name.
Settings –> Sheet Properties –> Sheet ID
STEP 2: Set the “OnOpen” Trigger in document properties and set the variable to Sheet ID.
Let us assume a variable name “SHEET” in this example.
Settings –> Document Properties –> Triggers –> Actions –> [Document Event Triggers] OnOpen –> Edit Actions –> Add –> Activate Sheet –> type value “=SHEET”
STEP 3: You are ready for the show. Use the command qv.exe <doc.qvw> /v<sheetid>
In my example this needs to be “d:Program FilesQlikViewQv.exe” test.qvw /vSHEET=1
How to LOAD data from a text file?
Assume your text file looks like this. Where, col1 and col2 are the column names. I call the file as “testtbl.txt”.
The script to load data from QlikView will be:
testtbl: <br />LOAD col1,col2 FROM testtbl.txt;<br />
If you have a Table Box UI element in the sheet it will display like this when you reload:
How to save data from QlikView to a QVD file?
Assuming, from the above example we have data already in “testtbl” variable. Use this statement to store the data to a physical QVD file.
STORE testtbl into test.qvd;
You can see a physical file in desk with name “test.qvd” is created. If you try to open the file in notepad, you can see an XML format data.
How to read data from QVD file?
Reading is similar to reading text files. But only difference is, you have to tell QlikView that this is a QVD file.
LOAD col1,col2 FROM test.qvd (qvd);
Note the “(qvd)” in the statement. Otherwize this will not work.
Here is a sample which demonstrates two aspects:
- Load script dynamically based on the parameter received from the QlikView Publisher
- Based on some criteria, load a flat file data
<br />"MyArg" is the argument which is used in the Publisher as parameter. When this .qvw file is invoked from Publisher, MyArg variable will get populated.<br /><br />//SET MyArg = "556-o"; // Comment this when you test with Publisher<br /><br />//Below lines are for parsing the argument <br />LET AnalysisID = Left(MyArg, Index(MyArg,'-')-1);<br />LET ReportGroup = Right(MyArg, Len(MyArg)-Index(MyArg,'-'));<br /><br />// Example filename will be : test_praveen_556.txt<br />$(Must_Include=test_praveen_$(AnalysisID).txt)<br /><br />//Example DataFileName will be testdata.txt, which was the contents read by the above statement. ReportGroup is the parameter which we parsed from the Publisher parameter.<br /><br />LOAD @1<br />FROM<br />[$(DataFileName)]<br />(txt, codepage is 1252, no labels, delimiter is 't', msq)<br />where @1 like '*$(ReportGroup)*';<br />
In case if you face issues while trying to apply your license and you get an error message like “Failed to retrieve LEF from the registration server”, “unable to connect” etc., try obtaining the LEF info manually from this URL: