Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Is it possible, within the ajax client, to create a button that will send a chart to excel? So far from my experience you can only create macros that send objects to excel with the IE Plugin.
It would seem possible because the button on top of the charts works fine, unfortuanitally I need this functionality from a button.
unfortunately*
Hi,
do you need to export the chart data into excel or the whole image of the chart?
Regards,
Daniel
Hello Daniel,
Just the chart data would be fine. It is a pivot table.
Thanks,
Tyler
Hi Tyler,
in AJAX most of the macro functionalities doesn't work. I had the same problem and I solved it by exporting first the chart data via macro to a txt file. Then, by a Shell Script, you can open an excel file with a macro inside which automatically fetches the data of the txt file and fills the excel file with it.
I know, it sounds a bit complicated, but it's the only workaround, I found.
Exporting the data of any chart to a txt file is simple:
Sub ExportChart()
path = "D:\Export1.txt" ' Set your path, where the txt file shall be created
Set chart1 = ActiveDocument.GetSheetObject("CH01") 'CH01 has to be the ID of your chart
chart1.Export path, ";"
' Open an Excel File via Shell
cmd = "D:\ExcelFileWithMacro.xls"
Set WSH = CreateObject("WScript.Shell")
WSH.Run (cmd),0
End Sub
Let me know if this helps you.
Regards,
Daniel
Hey Daniel,
This is very helpful and I think I am moving in the right direction. I couldn't get the shell script to work but this export can create .csv files, which is nice. Here is the macro I am running now:
Sub ExportChart
path = "C:\Export1.csv" ' Set your path, where the txt file shall be created
Set chart1 = ActiveDocument.GetSheetObject("CH01") 'CH01 has to be the ID of your chart
chart1.Export path, ","
End Sub
Do you know of a way to prompt the opening of this Export1.csv file? I tried a 'Launch' action but that only works in the developer not from the ajax client. Launch seems to just open a new tab when run from the ajax client.
Thanks,
Tyler
Hi Tyler,
the shell script works, when you set the security levels on the left side of the macro editor to "System Access", not the "safe mode".
Opening the file for the user means download it via an URL, because otherwise the file is only opened on the server which the user can't see.
So I'm suggesting using a fileserver (if you have no existing one, you can try the HFS (HTTP File Server), which is a freeware tool and don't need any installations). Then you can make a new button with a "Open URL" action in it which opens (download) the file. Then the user can see it.
The problem, why you shouldn't put the Open URL action into the button which starts the export Macro is that the actions don't wait til the macro finished. They are immediately triggered, after the macro launched. And because the macro takes a millisecond longer, the Open URL Action won't fetch the new exported file.
Hope this helps you.
Regards,
Daniel
For some reason I can't use the above code to export to csv in ajax. Security is set to System Access...what other settings are needed?
Thanks
Paul
Have you looked at the ServerSideExportEx API in the API Guide? I believe this is what you will need in order to use the button in Ajax client.
I think you're right. Unfortunately there seems to be a bug in QV11 where only xml export works using this method. I did some research and found someone else reported this also:
http://community.qlik.com/message/190250#190250
Thanks for the help!