Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
gidon500
Creator II
Creator II

Store to txt file encoding ansi

Hello

I am using this script

aa:
LOAD * INLINE [
F1
1
2
3
4
]
;

STORE * from aa into aaa.txt (txt) ;

setting is:  

default export encoding is ansi  in document properties

default user setting is Encoding ansi

the problem is that the aaa.txt file encoding is UTF-8

I need it ansi .

what am I doing wrong  ?

thanks

gidon

11 Replies
gidon500
Creator II
Creator II
Author


TableToAnsi:
LOAD * INLINE [
    F1
    1
    2
    3
    4
];

Call ExportToTextfile ()  ;

exit SCRIPT ;

// the macro stores the results of the table "TableToAnsi" into the TXT file.

// this is the macro


Sub ExportToTextfile

    Set tableObject = ActiveDocument.GetSheetObject("TB01")

    tableObject.Export "C:/TEST.txt",Chr(9)

End Sub

Miguel_Angel_Baeyens

So basically:

  • the Sub ... End Sub script must be in the script before the Call function, else the function is not defined and therefore the error.
  • As mentioned before, during the load script you cannot use .GetSheetObject() as the object does not exist yet, this may not cause any error but will result in an empty file. Instead, you have to create a table in the script and export such table.

The sequence is

  1. Define function
  2. Load data
  3. Call function

I think the example by Chris is quite good, but there are sure others in the Qlik Community.