Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations John Tel on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Create Excel PivotTable from Javascript

Status
Not open for further replies.

DannyLondon

Programmer
Nov 19, 2002
33
GB
Hello all

I am trying to create a pivot table in Excel, driven by JavaScript from my intranet page. The code works beautifully within VBA, but it keeps falling over on the PivotCache object in JS. The code is below. I would be very grateful for any suggestions on why this may be.

I have looked into the PivotTableWizard method, but I want to use the MSOLAP driver, and this is not possible for the wizard.

// Open Excel
objApplication = new ActiveXObject("Excel.Application.9")
objApplication.visible = true;
objBook = objApplication.Workbooks.Add()

wksReport = objBook.Worksheets(1)
wksReport.Name = "Report"

objPivotCache = objApplication.ActiveWorkbook.PivotCaches.Add(2, "") // xlExternal
objPivotCache.Connection = Connection
objPivotCache.CommandType = 1 // xlCmdCube
objPivotCache.CommandText = "OCWCube"
objPivotCache.MaintainConnection = True

objPivotTable = objPivotCache.CreatePivotTable(Range("A1"), "DrillDown")

Thanks
Danny...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top