Creating OWC.PivotTable object in a c# class

S

S. David Kyle

I have a classic asp application where I create a pivot table object like this:
Set oPivot = Server.CreateObject("OWC11.PivotTable")

I want to do the same thing in a class. The problem is that it doesn't
appear that the pivot table component initializes properly. here is my code:

private AxMicrosoft.Office.Interop.Owc11.AxPivotTable axPivotTable1;

public void tester()
{

this.axPivotTable1 = new
AxMicrosoft.Office.Interop.Owc11.AxPivotTable();
this.axPivotTable1.Name = "axPivotTable1";
ADODB.ConnectionClass conn = new ADODB.ConnectionClass();
ADODB.RecordsetClass rs = new ADODB.RecordsetClass();
conn.Open("PROVIDER=SQLOLEDB;Data Source=SERVERNAME;Initial
Catalog=DATABASENAME;Integrated Security=SSPI", "", "", 0);
rs.Open("SELECT * FROM Table", conn,
ADODB.CursorTypeEnum.adOpenStatic, ADODB.LockTypeEnum.adLockUnspecified, 0);
this.axPivotTable1.DataSource = (msdatasrc.DataSource)rs;

Console.Write(this.axPivotTable1.HTMLData);


}

If i have the PivotTable control in a form everything works fine.

Thanks in advance,
david
 
Top