Report paper orientation changed through an extender rule

andreeaG
New Contributor II

Hello community, 

Has anyone used a cube view extender rule to change between the portrait/landscape paper orientation on a PDF report? In our example, we are trying to use a parameter that allows the user to select the column template set needed, and although the idea of calling out the CV column template name sounds logical, I don't think OS has the capability to do this, similar to a column name as shown in the below example. Putting it out there just in case, as I promised our user we will explore different avenues.

andreeaG_2-1722635188170.png

andreeaG_1-1722635162003.png

 

1 ACCEPTED SOLUTION

T_Kress
Contributor III

Yes, we used a cube view extender BR and based upon the forecast scenario name it would change the orientation from portrait to landscape.  Here is our code:

 

Namespace OneStream.BusinessRule.CubeViewExtender.CUSTOMER_PageOrientation
	Public Class MainClass
		Public Function Main(ByVal si As SessionInfo, ByVal globals As BRGlobals, ByVal api As Object, ByVal args As CVExtenderArgs) As Object
			Try
				Select Case args.FunctionType
					Case Is = CVExtenderFunctionType.GetReportOptions

                    	Dim cvER As CVExtenderReport = args.Report.CurrentUIItem.Report
						Dim uiItem As CVExtenderReportUIItem = args.Report.CurrentUIItem
						
						If uiItem.UIItemType = XFReportUIItemType.PageFooterPageNumber Then
							uiitem.SetPageNumberDisplayInfo (True,"Page {0} of {1}")
						End If	

						' --- Option 1: Using native DevExpress report classes , but requires Referenced Assembly to correct version of DevExpress.XtraReports.<version>.dll
						' Dim xtraReport As DevExpress.XtraReports.UI.XtraReport = cver.XRReport
						' xtraReport.Landscape = True
						' --- Option 2: Using System.Reflection to query the DevExpress class through generic objects. Slower to execute, but doesn't require hard-configured Referenced Assembly to the exact server path + version of DevExpress

                       Dim cvERProperty As System.Reflection.PropertyInfo = cvER.GetType().GetProperty("XRReport")
					   Dim currScenario As String = ScenarioDimHelper.GetNameFromID(si, si.WorkflowClusterPk.ScenarioKey)

                       If cvERProperty IsNot Nothing Then
						   If CurrScenario.XFContainsIgnoreCase("01") Or CurrScenario.XFContainsIgnoreCase("04") Or CurrScenario.XFContainsIgnoreCase("07") Or CurrScenario.XFContainsIgnoreCase("10") Then    
'				            Return "IsColumnVisible = True,Bold=True"
							Dim xtraReport As Object = cvERProperty.GetValue(cvER)
                            xtraReport.Landscape = True
						Else 
							Dim xtraReport As Object = cvERProperty.GetValue(cvER)
                            xtraReport.Landscape = False
						End If
                       End If

                   End Select

'                     XFBR(CUSTOMER_XFBRStrings, QTRFcst, CurrScenario = |WFScenario|)

'                       Dim CurrScenario As String = args.NameValuePairs.XFGetValue("CurrScenario")
					   
'                       If CurrScenario.XFContainsIgnoreCase("01") Or CurrScenario.XFContainsIgnoreCase("04") Or CurrScenario.XFContainsIgnoreCase("07") Or CurrScenario.XFContainsIgnoreCase("10") Then    
'				            Return "IsColumnVisible = True,Bold=True"
'		                   'qtr end is extra columns and landscape
'                       Else     
'                           Return "IsColumnVisible = False,Bold=False"
'                           'non qtr end are less columns and potrait
'                       End If  
				Return Nothing
		Catch ex As Exception
			Throw ErrorHandler.LogWrite(si, New XFException(si, ex))
        End Try
        End Function
	End Class
End Namespace

Then in all the cube views where this applied, we added the rule here:

T_Kress_0-1722636796433.png

 

 

Teresa C. Kress
Principal Delivery Manager Partner Enablement | OneStream Software

View solution in original post

2 REPLIES 2

T_Kress
Contributor III

Yes, we used a cube view extender BR and based upon the forecast scenario name it would change the orientation from portrait to landscape.  Here is our code:

 

Namespace OneStream.BusinessRule.CubeViewExtender.CUSTOMER_PageOrientation
	Public Class MainClass
		Public Function Main(ByVal si As SessionInfo, ByVal globals As BRGlobals, ByVal api As Object, ByVal args As CVExtenderArgs) As Object
			Try
				Select Case args.FunctionType
					Case Is = CVExtenderFunctionType.GetReportOptions

                    	Dim cvER As CVExtenderReport = args.Report.CurrentUIItem.Report
						Dim uiItem As CVExtenderReportUIItem = args.Report.CurrentUIItem
						
						If uiItem.UIItemType = XFReportUIItemType.PageFooterPageNumber Then
							uiitem.SetPageNumberDisplayInfo (True,"Page {0} of {1}")
						End If	

						' --- Option 1: Using native DevExpress report classes , but requires Referenced Assembly to correct version of DevExpress.XtraReports.<version>.dll
						' Dim xtraReport As DevExpress.XtraReports.UI.XtraReport = cver.XRReport
						' xtraReport.Landscape = True
						' --- Option 2: Using System.Reflection to query the DevExpress class through generic objects. Slower to execute, but doesn't require hard-configured Referenced Assembly to the exact server path + version of DevExpress

                       Dim cvERProperty As System.Reflection.PropertyInfo = cvER.GetType().GetProperty("XRReport")
					   Dim currScenario As String = ScenarioDimHelper.GetNameFromID(si, si.WorkflowClusterPk.ScenarioKey)

                       If cvERProperty IsNot Nothing Then
						   If CurrScenario.XFContainsIgnoreCase("01") Or CurrScenario.XFContainsIgnoreCase("04") Or CurrScenario.XFContainsIgnoreCase("07") Or CurrScenario.XFContainsIgnoreCase("10") Then    
'				            Return "IsColumnVisible = True,Bold=True"
							Dim xtraReport As Object = cvERProperty.GetValue(cvER)
                            xtraReport.Landscape = True
						Else 
							Dim xtraReport As Object = cvERProperty.GetValue(cvER)
                            xtraReport.Landscape = False
						End If
                       End If

                   End Select

'                     XFBR(CUSTOMER_XFBRStrings, QTRFcst, CurrScenario = |WFScenario|)

'                       Dim CurrScenario As String = args.NameValuePairs.XFGetValue("CurrScenario")
					   
'                       If CurrScenario.XFContainsIgnoreCase("01") Or CurrScenario.XFContainsIgnoreCase("04") Or CurrScenario.XFContainsIgnoreCase("07") Or CurrScenario.XFContainsIgnoreCase("10") Then    
'				            Return "IsColumnVisible = True,Bold=True"
'		                   'qtr end is extra columns and landscape
'                       Else     
'                           Return "IsColumnVisible = False,Bold=False"
'                           'non qtr end are less columns and potrait
'                       End If  
				Return Nothing
		Catch ex As Exception
			Throw ErrorHandler.LogWrite(si, New XFException(si, ex))
        End Try
        End Function
	End Class
End Namespace

Then in all the cube views where this applied, we added the rule here:

T_Kress_0-1722636796433.png

 

 

Teresa C. Kress
Principal Delivery Manager Partner Enablement | OneStream Software

andreeaG
New Contributor II

Hi Teresa! Thank you for replying and providing us with the code you used. We were able to modify it to fit the reporting needs. Adding the code here for other users looking for this in the future.

The client wanted the cube view PDF report to change orientation to landscape when they selected a specific column template on their prompt. 

If "Col_CVPeriod" was selected, the orientation defaulted to landscape = false (portrait)

If "Col_12M_Trend" was selected, the orientation changed to landscape = true

andreeaG_1-1723151671975.png

 

andreeaG_2-1723151777569.png

	Public Class MainClass
		Public Function Main(ByVal si As SessionInfo, ByVal globals As BRGlobals, ByVal api As Object, ByVal args As CVExtenderArgs) As Object
			Try
				Select Case args.FunctionType
					Case Is = CVExtenderFunctionType.GetReportOptions

						'change to landscape if certain column set is selected
                    	Dim cvER As CVExtenderReport = args.Report.CurrentUIItem.Report					
						Dim cvERProperty As System.Reflection.PropertyInfo = cvER.GetType().GetProperty("XRReport")
						Dim sValue As String = args.CubeView.CubeViewNameForSharingAllCols
						
						If sValue.XFEqualsIgnoreCase("Col_12M_Trend")
							Dim xtraReport As Object = cvERProperty.GetValue(cvER)
                            xtraReport.Landscape = True
						End If
						
				End Select

				Return Nothing
			Catch ex As Exception
				Throw ErrorHandler.LogWrite(si, New XFException(si, ex))
			End Try
		End Function
	End Class