Qlik Community

QlikView Documents

Documents for QlikView related information.

Announcements
QlikView Fans! We’d love to hear from you.
Share your QlikView feedback with the product team… Click here to participate in our 5-minute survey.
Rules, plus terms and conditions, can be found here.

QlikView App: Export Chart and Sheet to an Image File

MVP
MVP

QlikView App: Export Chart and Sheet to an Image File

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/

Attachments
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,

MVP
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

MVP
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

MVP
MVP

No worries, glad it now works.

- Steve

csurajbhan
New 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....

MVP
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
New Contributor II

thnx 4 d help...

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

MVP
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
New Contributor III

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
Revision #:
1 of 1
Last update:
‎05-29-2013 05:55 PM
Updated by: