Skip to main content
Announcements
NEW: Seamless Public Data Sharing with Qlik's New Anonymous Access Capability: TELL ME MORE!
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

Export to CSV and Dynamically Add Column Header

I have the following macro, which outputs a csv file:

SUB csv_Macro

SET sObject = ActiveDocument.GetSheetObject("CH01")

sObject.Export "C:\Users\....\TestFile.csv", ", "

END SUB

I was hoping to add additional logic so that I could rename the first two blank columns in row 1.

For example, if I am outputting a file with five columns, then I want cell D1 to be labeled as "LineItem" and cell E1 to be labeled as "Amount"

Similarly, if the file I am outputting has three columns, then I want cell B1 to be labeled as "LineItem" and cell C1 to be labeled as "Amount"

I am new to coding Macros in QlikView, and while I have gotten the export to work, I would appreciate any help with adding the additional logic above.

4 Replies
kaushiknsolanki
Partner Ambassador/MVP
Partner Ambassador/MVP

Hi,

You dont need to do anything.

When you export the chart it will be exported with labels given.

Regards,

Kaushik Solanki

Please remember to hit the 'Like' button and for helpful answers and resolutions, click on the 'Accept As Solution' button. Cheers!
Anonymous
Not applicable
Author

In the charts that I am exporting, while the number of columns in each chart may be different, the last two columns in every chart do not have headers. I am hoping to build the logic noted above in the QlikView macro, as opposed to maintaining a separate macro in Microsoft Excel.

kaushiknsolanki
Partner Ambassador/MVP
Partner Ambassador/MVP

Hi,

That is what i want to say, why you want to use a macro when you can give a labels in Qlik Chart, So if you manage them properly in chart you dont need a macro to re do the same thing.

Regards,

Kaushik Solanki

Please remember to hit the 'Like' button and for helpful answers and resolutions, click on the 'Accept As Solution' button. Cheers!
Anonymous
Not applicable
Author

As you can see in the attached image, I have a number of expressions in a single column, and so while I can label each expression individually (assets, liabilities, etc) in the chart "Properties", I need QV_Output.jpga header for all of my equations.