Qlik Community

QlikView Documents

Documents for QlikView related information.

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.

Macro that combines two sheet objects and export as a single image.

sasiparupudi1
Honored Contributor III

Macro that combines two sheet objects and export as a single image.

Hi Friends,

I have come across some questions posted by the community members asking if there is any way to combine 2 or more sheet objects and export them into a single image file.

While this is not possible directly as Qlikview objects can only be exported one at a time into an output file, there is a workaround available.

The workaround is to programatically create a container object, load the sheet objects into it in a grid style and export the container object as a picture file. While this idea is not entirely new, I thought I would come up with a working example.

Please see the attached qvw and let me know if it is of any use for you guys.. Hope that somebody will find it useful.

In the attached file, I have two sample chart objects and a button. The button has an action that calls a macro that does the following

  • Create a container object
  • Set its style to 2X1 grid
  • Add the two chart objects to the container
  • Call containers export method to export it as a picture into the target file

Here is the macro code.

Sub Export

     Chart1="Document\CH04"

     Chart2="Document\CH02"

     TargetFile="c:\aps\Container.png"

     Call ExportContainer(Chart1,Chart2,TargetFile)

End Sub

Sub ExportContainer(Chart1,Chart2,TargetFile)

    set ContainerObj = ActiveDocument.Sheets("Main").CreateContainer

    set ContProp=ContainerObj.GetProperties

    ContProp.ContainedObjects.Add

    ContProp.Mode=1

    ContProp.GridColumns=2

    ContProp.GridRows=1

    ContProp.ShowObjectTypeIcons=true

    ContProp.ContainedObjects.Add

    ContProp.ContainedObjects.Item(0).Def.ObjectId = Chart1

    ContProp.ContainedObjects.Item(0).Text.v =Chart1

    ContProp.ContainedObjects.Add

    ContProp.ContainedObjects.Item(1).Def.ObjectId =Chart1

    ContProp.ContainedObjects.Item(1).Text.v = Chart1

    ContainerObj.SetProperties ContProp

    ActiveDocument.GetApplication.WaitForIdle

    ContainerObj.ExportBitmapToFile TargetFile

    ContainerObj.Close

End Sub

Please checkout my other blog post

Loop through a dimension and export a chart into power point

Attachments
Comments
bnelson111
Contributor

Very good

Version history
Revision #:
1 of 1
Last update:
‎03-02-2017 03:06 PM
Updated by: