2013 C# connection to PowerPivot DataModel
Asked Answered
A

1

0

This article Connecting to PowerPivot with C# is the closest to my question but it seems that it is out of date. I attempted the methods they showed in the answer but the example

 ThisWorkbook.Connections["PowerPivot Data"].OLEDBConnection.ADOConnection

Does not return the connection information, rather an exception.

But I was able to access the PP Data Model using:

ThisAddIn.Current.Application.ActiveWorkbook.Connections[1]. ModelTables[1].ModelTableColumns[1].Name`

But the object only allows you to look at the column names in the model. I wasn't able to get the connection information or anything.

ThisAddIn.Current.Application.ActiveWorkbook.Connections[1].ModelConnection.ADOConnection`

causes an exception and so does:

ThisAddIn.Current.Application.ActiveWorkbook.Connections[1].OLEDBConnection.ADOConnection

MY QUESTIONS

  • Have I made a mistake in my code?
  • Is there another method to connect to the datamodel that I haven't listed above?
  • Is it possible to read the records in the datamodel? (I was able to read column names)

Thank you for your time!

Amby answered 8/7, 2014 at 23:56 Comment(1)
Also was able to connect to get name with this ThisAddIn.Current.Application.ActiveWorkbook.Model.Name;Amby
A
-1

string ConnString = "Provider=MSOLAP;Data Source=$Embedded$; Locale Identifier=1033;Location=" + ThisAddIn.Current.Application.ActiveWorkbook.FullName + ";SQLQueryMode=DataKeys";

Microsoft.AnalysisServices.Server OlapServer = new Microsoft.AnalysisServices.Server();

OlapServer.Connect(ConnString);

Amby answered 15/7, 2014 at 16:16 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.