Skip to main content
Announcements
Qlik Connect 2025: 3 days of full immersion in data, analytics, and AI. May 13-15 | Orlando, FL: Learn More
cancel
Showing results for 
Search instead for 
Did you mean: 
manoranjan_d
Specialist
Specialist

send to excel for the two pie chart

Hi all,

I am having two pie chart for this i need a common send to excel button how can i achieve this, since my client said he don't want separate send to excel for the each of the chart , he need common button of XL and when they hit it should pull the two pic chart data to excel .

2 Replies
saimahasan
Partner - Creator III
Partner - Creator III

you need to have macro to do this

krishnacbe
Partner - Specialist III
Partner - Specialist III

Hi,

Below code helps to move the charts to excel. you need to call this on button trigger.

Sub ExcelExpwCaption
     'Set the path where the excel will be saved
     filePath = "C:\Users\nm36505\Desktop\SD QV\test.xls"

     'Create the Excel spreadsheet
     Set excelFile = CreateObject("Excel.Application")
     excelFile.Visible = true
     'Create the WorkBook
     Set curWorkBook = excelFile.WorkBooks.Add
     'Create the Sheet
     Set curSheet = curWorkBook.WorkSheets(1)

     'Get the chart we want to export
     Set tableToExport = ActiveDocument.GetSheetObject("CH82")
     Set chartProperties = tableToExport.GetProperties
     tableToExport.CopyTableToClipboard true

     'Get the caption
     chartCaption = tableToExport.GetCaption.Name.v
     'MsgBox chartCaption

     'Set the first cell with the caption
     curSheet.Range("A1") = chartCaption
     'Paste the rest of the chart
     curSheet.Paste curSheet.Range("A2")
     excelFile.Visible = true

     'Save the file and quit excel
     curWorkBook.SaveAs filePath
     curWorkBook.Close
     excelFile.Quit

     'Cleanup
     Set curWorkBook = nothing
     Set excelFile = nothing
End Sub

Note: Macro will not work in Ajax mode.