Qlik Community

QlikView Scripting

Discussion Board for collaboration on QlikView Scripting.

Announcements

Breathe easy -- you now have more time to plan your next steps with Qlik!
QlikView 11.2 Extended Support is now valid through December 31, 2020. Click here for more information.

Not applicable

VB Macro to Export Table to CSV with No headers !

Hi - Can anyone help ?

I have the following vb macro that exports data to a csv file :

Sub ExportToFile

'Download Sheet ojbect data to CSV

set sObject = ActiveDocument.GetSheetObject("TB01")

sObject.Export "C:\download\BIB\TestFile.csv", ", "

End Sub

Works perfectly except I don't want the field headers.

After reading a few articles one work around is to kick of a bat file that contains:

TestFile.csv | find /V "Sort Code,Account Name,Account Number,Amount,Reference,BACS CODE" > noheader.csv

However this just leaves a blank file.

Does anyone have a solution ?????

Tags (1)
1 Solution

Accepted Solutions
Not applicable

Re: VB Macro to Export Table to CSV with No headers !

For reference - the only way I could make it work was to export the csv file then kick off a bat file to remove the header. If interested my macro was as follows:

Sub ExportToFile

'Download Sheet ojbect data to CSV

set sObject = ActiveDocument.GetSheetObject("TB01")

sObject.Export "C:\download\BIB\TestFile.csv", ", "

'Run Bat File to remove headers

Dim obj

Set obj = CreateObject("WScript.Shell")

obj.Run "C:\download\BIB\test.bat ", , TRUE

End Sub

Then the script in the BAT file kicks off another bit of script. BAT file content is as follows :

c:\download\BIB\DeleteFirstLine.vbs "c:\download\BIB\TestFile.csv"

And the vbs file is attached:

(A bit long winded but it worked)

5 Replies
isaiah82
Not applicable

VB Macro to Export Table to CSV with No headers !

I don't believe there is an option with the API to exclude header rows on export.  I notice that, even if you check the "Supress Header Row" on chart properties, the header row still exists on export.

Your batch command should work; it looks like maybe you're missing "type" command in front of the command in your post.  Also, the string following the /v must be perfect with case, spacing etc.

type TestFile.csv | find /V "Sort Code,Account Name,Account Number,Amount,Reference,BACS CODE" > noheader.csv

-Isaiah

Not applicable

Re: VB Macro to Export Table to CSV with No headers !

For reference - the only way I could make it work was to export the csv file then kick off a bat file to remove the header. If interested my macro was as follows:

Sub ExportToFile

'Download Sheet ojbect data to CSV

set sObject = ActiveDocument.GetSheetObject("TB01")

sObject.Export "C:\download\BIB\TestFile.csv", ", "

'Run Bat File to remove headers

Dim obj

Set obj = CreateObject("WScript.Shell")

obj.Run "C:\download\BIB\test.bat ", , TRUE

End Sub

Then the script in the BAT file kicks off another bit of script. BAT file content is as follows :

c:\download\BIB\DeleteFirstLine.vbs "c:\download\BIB\TestFile.csv"

And the vbs file is attached:

(A bit long winded but it worked)

Not applicable

Re: VB Macro to Export Table to CSV with No headers !

hi, the above vbs is not working for me. When I run the Macro my Wscript shell is not working

Not applicable

Re: VB Macro to Export Table to CSV with No headers !

Hi ,

Is there any way to add 2 rows in the top of the header for this same example

thnx

Not applicable

Re: VB Macro to Export Table to CSV with No headers !

This Solution works Great!