Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

ExportEx not working

Hello,

I am having an issue with Export Ex when I try to export a Graph to .xls This is the code I am using:

set chart_kpi5_1 = .doc.GetSheetObject("CH368")

chart_kpi5_1.ExportEx"C:\Folder1\test.xls",5



The problem is that when I go to that folder it has not created anything!

Does anyone had the same problem?

Thank you!

14 Replies
marcus_sommer

In this case you might need to make these object visible - this meant a minimized chart could not be exported as image, here another example from the APIGuide.

ActiveDocument.GetSheetObject("CH01").Restore

rem ** restore all sheet objects on sheet Main **

set s=ActiveDocument.Sheets("Main")

for i=0 to s.NoOfSheetObjects-1

    s.SheetObjects(i).Restore

next

Also it might help to change the export-feature from ExportEx to Export or to ExportBitmapToFile.

- Marcus

tamilarasu
Champion
Champion

Hello Miguel,

Sorry for the late reply. I had left for the day and I saw your message before an hour. After gathering some knowledge from google, I found a solution for you.

Below code exports the graph into .XLS format.

'==========================================================

Sub includeFile(ByVal fSpec)

    executeGlobal CreateObject("Scripting.FileSystemObject").openTextFile(fSpec).readAll()

End Sub

includeFile "QvUtils.vbs"

with New QlikView

'==========================================================

'File Path & Date Format => YYYYMMDD_HHMMSS

    strPath = GetAbsolutePath("..\Output\")

    strDate = Year(now) & Right ("0" & Month(Now),2) & Right ("0" & Day(Now),2)

    strTimeStamp = Right("0" & Hour(Now),2) & Right ("0" & Minute(Now),2) & Right ("0" & Second(Now),2)

    strFile = StrPath & "Test " & strDate & "_" & strTimeStamp & ".xls"

'==========================================================

   .open("..\App\1.qvw")

    set chart = .doc.GetSheetObject("CH01")

    chart.CopyBitmapToClipboard

'========================================================== 

    Set obj = CreateObject("Excel.Application")

    obj.visible = False

    Set objWb = obj.Workbooks.Add

    obj.Activeworkbook.Activesheet.Paste()

    obj.Activeworkbook.SaveAs strFile, -4143   '51 for xlsx

    obj.Quit

    obj.visible = True

    Set chart = Nothing

    Set obj  = Nothing

    Set objWb = Nothing

'=========================================================

  .doc.CloseDoc

  .Quit

  Msgbox "Graph Exported Successfully!!", VbOKOnly + VbInformation ,"VBScipt Status"

end with

Output:

Untitled.png


  If you want to save the graph as JPG format, you can use the below code.


Sub includeFile(ByVal fSpec)

    executeGlobal CreateObject("Scripting.FileSystemObject").openTextFile(fSpec).readAll()

End Sub


includeFile "QvUtils.vbs"

with New QlikView

  .open("..\App\1.qvw")

  set chart = .doc.GetSheetObject("CH01")

  chart.ExportBitmapToFile  (GetAbsolutePath("..\Output\Test.jpg"))

  .doc.CloseDoc

  .Quit

  Msgbox "Graph Exported (JPG) Successfully!!", VbOKOnly + VbInformation ,"VBScipt Status"

  Set chart = Nothing

end with

end w

I have attached all the tested files for your reference. Have a look and let me know if you still have any issues.

Not applicable
Author

Hi Tamil,

First of all thank you very much for your help and collaboration but that is not what I need... Maybe it is my fault as I have not explain myself very good. What I am trying to do is:

I have this object (that is a graph):

2016-04-25 08_56_53-qtnprinting - Remote Desktop Connection.png


And I want to do this:

2016-04-25 08_57_53-qtnprinting - Remote Desktop Connection.png

So I get this:

2016-04-25 08_59_06-qtnprinting - Remote Desktop Connection.png

That is why I was trying ExportEx because Graphs does not support ExportBiff...

Do you know how should I proceed in order to export that graph to excel using VBS?

Thank you very much again!

Regards,

tamilarasu
Champion
Champion

Miguel,

First of all, no need to say thanks and all. I am just sharing with you what I knew. If you could post your issues clearly, you might get answers quickly (almost four days in your case).


Now coming to your issue. Change below line .

chart.CopyBitmapToClipboard

chart.CopyTableToClipboard True


Actual Chart:

2.PNG


Output:

Capture.PNG


Seems you have opened wrong attachment. Herewith, I have attached the updated one.


Not applicable
Author

Thank you very much for your suppor Tamil!