Skip to main content
Announcements
ALERT: The Product Download page is currently unavailable. The team is investigating.

QlikView App: Export Chart and Sheet to an Image File

cancel
Showing results for 
Search instead for 
Did you mean: 
stevedark
Partner Ambassador/MVP
Partner Ambassador/MVP

QlikView App: Export Chart and Sheet to an Image File

Last Update:

May 29, 2013 5:55:54 PM

Updated By:

stevedark

Created date:

May 29, 2013 5:55:54 PM

Attachments

This example shows how to call a macro that saves image files for a selected sheet and chart to a specified location on reload.

The saved images could then be published via a web site or Wall Board, for example.

This QlikView was written in response to a post in the QlikView UK user group.

For other tutorial apps you can download and use, please see:

https://www.quickintelligence.co.uk/qlikview-examples/

Hope you find this app useful.

Steve Dark

http://www.quickintelligence.co.uk/

Comments
Not applicable

Hi Steve,

thanks for the exmaple. I adapted your macro to my application.

I just ran into a new Problem: I want to export/save more Graphics, but the code always stops after 24 items.

Do you have an idea for this topic??

Would be great,

stevedark
Partner Ambassador/MVP
Partner Ambassador/MVP

Hi Tobias,

Thanks for feeding back that this macro is working for you.  I've not hit that issue - but then I have not tried to export that many items.

Is the number of items variable - eg. if you export simpler items (eg. Text Areas) can you get more out?  This would imply some kind of time out.

Can you try creating multiple macros - perhaps one per sheet - and then firing each macro one after the other in a chain of Actions.  This may allow you to export all that you need to?

Hope that helps.

Steve

stevedark
Partner Ambassador/MVP
Partner Ambassador/MVP

The macro code used in this example is as follows:

public function ExportImage

  ActiveDocument.GetApplication.WaitForIdle

  ActiveDocument.GetSheetByID("DASH").Activate


  vFolder = ActiveDocument.GetVariable("vExportFolder").GetContent().String

  set obj = ActiveDocument.GetSheetByID("DASH")

ActiveDocument.GetApplication.WaitForIdle

  fileName = "ExportScreen_" & replace(replace(replace(date() & "_" & time(), "/", ""), ".", ""), ":", "") & ".png"

  ActiveDocument.GetApplication.WaitForIdle

  obj.ExportBitmapToFile vFolder & fileName

  set obj = ActiveDocument.GetSheetObject("EXPORT")

  ActiveDocument.GetApplication.WaitForIdle

  fileName = "ExportScreen_" & replace(replace(replace(date() & "_" & time(), "/", ""), ".", ""), ":", "") & ".png"

  ActiveDocument.GetApplication.WaitForIdle

  obj.ExportBitmapToFile vFolder & fileName

end function

You will need to modify the code to match the object name of the object which you wish to export.

Regards,

Steve

http://www.quickintelligence.co.uk/

Not applicable

Hi Steve,

i got it. As you suggested I split up the Code in pieces. It is more comfortable to adjust in case of changes in the document. now it works fine.

THanks again,

Tobias

stevedark
Partner Ambassador/MVP
Partner Ambassador/MVP

No worries, glad it now works.

- Steve

csurajbhan
Contributor II
Contributor II

hi,

while exporting image in mail body, i didn't get image outside border.

can u suggest how to get outside border of image in mail body....

stevedark
Partner Ambassador/MVP
Partner Ambassador/MVP

The missing border and (sometimes more of an issue) the caption of a chart happens whether you export the chart through the UI, copy and paste it or even pull it into a QlikView report.

If you need to get a border on there you could potentially post process the image with a graphics package that accepts a command line parameter.  This could then be called from the macro using a CMD function call?

What are you then pulling the image in to?  If it is going into a web page, for example, you could then put the border back on using HTML?

Hope that helps,

Steve

csurajbhan
Contributor II
Contributor II

thnx 4 d help...

but i got the solution in qlikview user prefe. setting itself....

stevedark
Partner Ambassador/MVP
Partner Ambassador/MVP

Sorry, I forgot that that had been added to the Export tab of the User

Preferences.  There was a time when this wasn't an option.

Glad you sorted it.

- Steve

richardouellett
Creator
Creator

Steve

I found this to be very helpful, but was not sure if it was working until I examined the code.  As a result, I added a message box at the bottom of your code below.  Do you know if QlikView has automation/OLE links to print this example if you are not in the QlikView application?  Thanks again

public function ExportImage

   

    ActiveDocument.GetApplication.WaitForIdle

   

    ActiveDocument.GetSheetByID("DASH").Activate

   

   

    vFolder = ActiveDocument.GetVariable("vExportFolder").GetContent().String

   

    set obj = ActiveDocument.GetSheetByID("DASH")

       

    ActiveDocument.GetApplication.WaitForIdle

   

    fileName = "ExportScreen_" & replace(replace(replace(date() & "_" & time(), "/", ""), ".", ""), ":", "") & ".png"

       

    ActiveDocument.GetApplication.WaitForIdle

   

    obj.ExportBitmapToFile vFolder & fileName

    set obj = ActiveDocument.GetSheetObject("EXPORT")

       

    ActiveDocument.GetApplication.WaitForIdle

   

    fileName = "ExportScreen_" & replace(replace(replace(date() & "_" & time(), "/", ""), ".", ""), ":", "") & ".png"

       

    ActiveDocument.GetApplication.WaitForIdle

   

    obj.ExportBitmapToFile vFolder & fileName

    message=msgbox(vFolder & fileName,0,"Export Image sent to...")

end function

Version history
Last update:
‎2013-05-29 05:55 PM
Updated by: