M
Michael Weiss
I am trying to get the following code below to work but
am running into an error. I am trying to create an
instance of an OWC10 Pivot Control on an ASP page on the
server then write the html out to the page via
Response.Write. The code is erring out on line 32(marked
with an '>>') with an undefined error. Has anyone tried
this code sample and gotten it to work? Any suggestions
would be greatly appreciated.
Thank you,
Michael
Code:
<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<html>
<head>
<title>HTML Pivot</title>
<meta http-equiv="Content-Type" content="text/html;
charset=iso-8859-1">
<%
Dim strMDX
'Create an in-memory reference to the PivotTable
component.
Dim oPivot
Set oPivot = Server.CreateObject("OWC10.PivotTable")
'Connect to the database and provide the commandtext
for the rowset.
oPivot.ConnectionString = "provider=msolap;data
source=MORPHEUS;" & _
"initial catalog=CarrierDM;integrated
security=SSPI"
'get the cube passed in:
oPivot.DataMember = "Carriers1"
sMdx = "SELECT" & vbCrLf
sMdx = sMdx & "{[CallType].Members} ON COLUMNS,"
& vbCrLf
sMdx = sMdx & "{[RegionCustomers].Members} ON
ROWS" & vbCrLf
sMdx = sMdx & "FROM [Carriers1]"
oPivot.CommandText = strMDX
Dim oView
Set oView = oPivot.ActiveView
'Add fields to the row axis and column axis for
grouping.
Dim oCategoryFields, oRowFields
oView.ColumnAxis.InsertFieldSet oCategoryFields
Set oRowFields = oView.FieldSets("[RegionCustomers]")
oRowFields.Fields(0).Caption = "Market"
oView.RowAxis.InsertFieldSet oRowFields
'Add a total for the Market fieldset.
oView.DataAxis.InsertTotal oView.Totals("Rated AMT")
oView.DataAxis.InsertTotal oView.Totals("CPM")
oView.Totals("Call Dur Mins").NumberFormat = "#,##0.0"
oView.Totals("Rated AMT").NumberFormat
= "$#,##0.0000"
oView.Totals("CPM").NumberFormat = "#,##0.0000"
'Collapse rows and columns.
oView.ExpandDetails = oPivot.Constants.plExpandNever
'Hide the Filter axis and change the PivotTable title.
oView.FilterAxis.Label.Visible = False
oView.TitleBar.Caption = "Call Type by Market"
oView.TitleBar.BackColor = "Black"
'Change colors and font style for the fields and
subtotals.
oPivot.BackColor = "Lavender"
oView.FieldLabelBackColor = "Lavender"
oView.TotalBackColor = "White"
oView.HeaderBackColor = "Gold"
oRowFields.Fields(0).GroupedBackColor = "MidnightBlue"
oRowFields.Fields(0).GroupedFont.Color = "Lavender"
oRowFields.Fields(0).SubtotalBackColor
= "LemonChiffon"
oRowFields.Fields(0).SubtotalLabelBackColor
= "MidNightBlue"
oRowFields.Fields(0).SubtotalFont.Bold = True
oRowFields.Fields(0).SubtotalLabelFont.Color
= "LemonChiffon"
oRowFields.Fields(0).SubtotalLabelFont.Bold = True
oCategoryFields.Fields(0).GroupedBackColor
= "MidnightBlue"
oCategoryFields.Fields(0).GroupedFont.Color
= "Lavender"
oCategoryFields.Fields(0).SubtotalBackColor = "Gold"
oCategoryFields.Fields(0).SubtotalLabelBackColor
= "MidNightBlue"
oCategoryFields.Fields(0).SubtotalLabelFont.Bold =
True
oCategoryFields.Fields(0).SubtotalLabelFont.Color
= "Lavender"
Response.Write("<div id='divoPivot'
style='position:absolute;top:100px;left:75px;'>")
Response.Write oPivot.HTMLData
Response.Write("</div>")
%>
</head>
<body>
</body>
</html>
am running into an error. I am trying to create an
instance of an OWC10 Pivot Control on an ASP page on the
server then write the html out to the page via
Response.Write. The code is erring out on line 32(marked
with an '>>') with an undefined error. Has anyone tried
this code sample and gotten it to work? Any suggestions
would be greatly appreciated.
Thank you,
Michael
Code:
<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<html>
<head>
<title>HTML Pivot</title>
<meta http-equiv="Content-Type" content="text/html;
charset=iso-8859-1">
<%
Dim strMDX
'Create an in-memory reference to the PivotTable
component.
Dim oPivot
Set oPivot = Server.CreateObject("OWC10.PivotTable")
'Connect to the database and provide the commandtext
for the rowset.
oPivot.ConnectionString = "provider=msolap;data
source=MORPHEUS;" & _
"initial catalog=CarrierDM;integrated
security=SSPI"
'get the cube passed in:
oPivot.DataMember = "Carriers1"
sMdx = "SELECT" & vbCrLf
sMdx = sMdx & "{[CallType].Members} ON COLUMNS,"
& vbCrLf
sMdx = sMdx & "{[RegionCustomers].Members} ON
ROWS" & vbCrLf
sMdx = sMdx & "FROM [Carriers1]"
oPivot.CommandText = strMDX
Dim oView
Set oView = oPivot.ActiveView
'Add fields to the row axis and column axis for
grouping.
Dim oCategoryFields, oRowFields
oCategoryFields.Fields(0).Caption = "Call Type"Set oCategoryFields = oView.FieldSets("[CallType]")
oView.ColumnAxis.InsertFieldSet oCategoryFields
Set oRowFields = oView.FieldSets("[RegionCustomers]")
oRowFields.Fields(0).Caption = "Market"
oView.RowAxis.InsertFieldSet oRowFields
'Add a total for the Market fieldset.
oView.DataAxis.InsertTotal oView.Totals("Rated AMT")
oView.DataAxis.InsertTotal oView.Totals("CPM")
oView.Totals("Call Dur Mins").NumberFormat = "#,##0.0"
oView.Totals("Rated AMT").NumberFormat
= "$#,##0.0000"
oView.Totals("CPM").NumberFormat = "#,##0.0000"
'Collapse rows and columns.
oView.ExpandDetails = oPivot.Constants.plExpandNever
'Hide the Filter axis and change the PivotTable title.
oView.FilterAxis.Label.Visible = False
oView.TitleBar.Caption = "Call Type by Market"
oView.TitleBar.BackColor = "Black"
'Change colors and font style for the fields and
subtotals.
oPivot.BackColor = "Lavender"
oView.FieldLabelBackColor = "Lavender"
oView.TotalBackColor = "White"
oView.HeaderBackColor = "Gold"
oRowFields.Fields(0).GroupedBackColor = "MidnightBlue"
oRowFields.Fields(0).GroupedFont.Color = "Lavender"
oRowFields.Fields(0).SubtotalBackColor
= "LemonChiffon"
oRowFields.Fields(0).SubtotalLabelBackColor
= "MidNightBlue"
oRowFields.Fields(0).SubtotalFont.Bold = True
oRowFields.Fields(0).SubtotalLabelFont.Color
= "LemonChiffon"
oRowFields.Fields(0).SubtotalLabelFont.Bold = True
oCategoryFields.Fields(0).GroupedBackColor
= "MidnightBlue"
oCategoryFields.Fields(0).GroupedFont.Color
= "Lavender"
oCategoryFields.Fields(0).SubtotalBackColor = "Gold"
oCategoryFields.Fields(0).SubtotalLabelBackColor
= "MidNightBlue"
oCategoryFields.Fields(0).SubtotalLabelFont.Bold =
True
oCategoryFields.Fields(0).SubtotalLabelFont.Color
= "Lavender"
Response.Write("<div id='divoPivot'
style='position:absolute;top:100px;left:75px;'>")
Response.Write oPivot.HTMLData
Response.Write("</div>")
%>
</head>
<body>
</body>
</html>