Qlik Community

Ask a Question

QlikView Documents

QlikView documentation and resources.

Announcements
Sept. 16, Qlik Product Portfolio Strategy and Roadmap for Data Integration 11 AM ET REGISTER NOW

QLIKVIEW AUTOMATION WITH PYTHON

matteo_mi
Partner
Partner

QLIKVIEW AUTOMATION WITH PYTHON

Long time ago I have developed a vbscript application to open qlikview, reduce some data according salesman filter, export the sales pivot table to excel and send an email with the excel sheet attached to the salesman using the blat.exe  application. The other day i was wondering if the same job could be executed using python. So after two minutes i was googling in search of some code snippets to easily make the python script.  After half an hour I was quite disappointed to not found anything already made so I opened Pycharm and started to make the basic code: a class to make an instance of qlikview, open the document, export the table, close the document, close the qlikview app.

Here the code tested on python 3.7:

from win32com.client import Dispatch
import pythoncom

class QlikView:
def __init__(self):
self.app = Dispatch('QlikTech.QlikView')

def OpenDoc(self, docname):
doc = self.app.OpenDoc(docname)
return doc

def CloseDoc(self, doc):
doc.CloseDoc()

def ManageDocument():
docname = "c:\EXAMPLE.qvw"
q = QlikView()
version = q.app.QvVersion()
print(version)
doc = q.OpenDoc(docname)
chart = doc.GetSheetObject("exampletable")
chart.ExportBiff("c:\exampletable.xls"

 q.CloseDoc(doc)
 q.app.Quit()

if __name__ == '__main__':
ManageDocument()

This is the code that I've written at today , for sure i will go on and rewrite all the app to send report attached in emails, if  someone need more information, just send me a message.

 

 

 

 

Labels (3)
Comments
shubshar
Contributor
Contributor

Thanks for sharing nice idea on Qlik - Python integration for automating the data export.

Is it possible to connect Qlikview report (deployed in QV server) to export data instead of referring to physical folder?

@matteo_mi 

0 Likes
LuizFernandoSena
Contributor
Contributor

Wow. You're the best!

Is that possible to open a Qlikview file (qvw) reload it to get the data updated without use the PyAutogui to send those keys??

0 Likes
danosoft
Creator III
Creator III

Sure, you can do that in a batch script like this (in windows):

 

"C:\Program Files\QlikView\qv.exe" /l /NoSecurity "<dir_qlik_project>\<qlikproject_name>.qvw"

 

0 Likes
LuizFernandoSena
Contributor
Contributor

I'm trying it out but I'm getting some indentation error. 

I'm using VSCODE. Is the code will work the same?

0 Likes
danosoft
Creator III
Creator III

Perhaps i not explained well, this is a script to execute in a batch file (dos file .bat)

0 Likes
dnagarajan
Partner
Partner

Great post.

@matteo_mi  Is there a way we can do the same from Access point documents with filter. Have you used a use case like this. 

 

@shubshar have you found a way to do from access point ?

0 Likes
danosoft
Creator III
Creator III

If i need to put more Table in same XLS , with ExportBiff i see i can choose only one... how can i put in same XLS more Table in different sheet?

Thanks

0 Likes
Version history
Revision #:
2 of 2
Last update:
‎2019-11-09 07:36 PM
Updated by:
 
Contributors