Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Export to Excel

Hi all, I have a table in QlikView and I want to create a Macro to export only 2 column ?

How can I do ?

Table in QlikView:

Num

Code

Price

Value

I want to export an Excel file with a Macro only with the field Num and Code

Thank you very much

7 Replies
m_woolf
Master II
Master II

Make another chart that has just the 2 columns you want to export.

Hide that chart.

Your macro will:

Unhide the chart

export it

Hide it again

robert_mika
Master III
Master III

This macro will export first 2 columns from object "CH01"

SUB CallExample

  set obj = ActiveDocument.GetSheetObject( "CH01" )

  w = obj.GetColumnCount

h=obj.GetRowCount

'

  Set objExcel = CreateObject("Excel.Application")

  objExcel.Workbooks.Add

  objExcel.Worksheets(1).select()

  objExcel.Visible = True

  set CellMatrix = obj.GetCells2(0,0,w,h)

  column = 1

  for cc=0 to 1

  objExcel.Cells(1,column).Value = CellMatrix(0)(cc).Text

'  objExcel.Cells(1,column).EntireRow.Font.Bold = True

  column = column +1

  next

  c = 1

  r =2

  for RowIter=1 to h-1

    for ColIter=0 to 1

      objExcel.Cells(r,c).Value = CellMatrix(RowIter)(ColIter).Text

      c = c +1

    next

  r = r+1

  c = 1

next

END SUB

amit_saini
Master III
Master III

Hi ,

Try this macro:

sub sendToExcel

    set XLApp = CreateObject("Excel.Application")

    XLApp.Visible = true

    set XLDoc = XLApp.Workbooks.Open("--------------------") 'set path to template file

    set XLSheet = XLDoc.Worksheets("A3")

    XLSheet.Activate

   

    set table = ActiveDocument.GetSheetObject( "CH642" )

    for RowIter = 1 to table.GetRowCount-1

    for ColIter =0 to table.GetColumnCount-1

        set cell = table.GetCell(RowIter,ColIter)

       

        Select Case ColIter

        Case 1

            cellAddress = "B9" 'Cell address to paste data in Excel

            pasteData cellAddress, cell.Text, Doc, XLSheet

        Case 2

            cellAddress = "H9" 'Cell address to paste data in Excel

            pasteData cellAddress, cell.Text, Doc, XLSheet

       

        End Select

       

        if ColIter = 18 then

            msgbox(cell.Text)

           

        end if

       

        if ColIter = 18 then

            msgbox(cell.Text)

            cellAddress = "B9" 'Cell address to paste data in Excel

            'Alex not used any more    fieldName = "Problem Desc." 'Field name in Qlikview

            pasteData cellAddress, cell.Text, Doc, XLSheet

        end if

           

    next

    next

       

end sub

Thanks,

AS

robert_mika
Master III
Master III

Have you tested this code?

amit_saini
Master III
Master III

Hi Mika,

Yes I'm using this in one of my current app.

Thanks,
AS

robert_mika
Master III
Master III

It does not work for me.

Could you explain steps in your code?

amit_saini
Master III
Master III

Mika,

Please see the attachment.

Hope this will help you!

Thanks,

AS