SSRS page numbers in page footer

允我心安 提交于 2019-12-31 07:31:12

问题


I wish to not include the page number (in the page footer) for the first 10 pages of the report (i.e. page 1-10). Page 1 should read i, page 2 should read ii and page 3 should read iii and so on (in roman numerals).... When it gets to page 11, this should reset the page numbers

Does anyone know of the expression I can use to achieve this. So if GlobalPage number = 1,2,3,4,5,6,7,8,9,10 do not display, or compensate the globals page number for something else.....Is this possible.


回答1:


You'll have to manually change the value i.e. putting something similar to the following in the footer:

IIf(Globals!PageNumber=1, "i", ...

Alternativally you could use a user function try VBA for number to roman numeral




回答2:


We'll do ths with some custom code to keep flexibility. Microsoft have some code to do the Roman numeral conversion so we'll adapt this.

Let's add the custom code we need: one function to convert an integer to a Roman numeral and one function to work out what sort of numeral to provide.

Function PageNumber(page As Integer, startArabic As Integer) As String
  If page <= startArabic Then
    PageNumber = IntegerToRoman(page)
  Else
    PageNumber = (page - startArabic).ToString()
  End If
End Function

Function IntegerToRoman (ByVal N As Integer) As String
  Const Digits = "ivxlcdm" 
  Dim I As Integer
  Dim Digit As Integer
  Dim Temp As String 

  I = 1 
  Temp = "" 

  Do While N > 0 
    Digit = N Mod 10 
    N = N \ 10 
    Select Case Digit 
      Case 1 
        Temp = Mid(Digits, I, 1) & Temp 
      Case 2 
        Temp = Mid(Digits, I, 1) & Mid(Digits, I, 1) & Temp 
      Case 3 
        Temp = Mid(Digits, I, 1) & Mid(Digits, I, 1) & Mid(Digits, I, 1) & Temp 
      Case 4 
        Temp = Mid(Digits, I, 2) & Temp 
      Case 5 
        Temp = Mid(Digits, I + 1, 1) & Temp 
      Case 6 
        Temp = Mid(Digits, I + 1, 1) & Mid(Digits, I, 1) & Temp 
      Case 7 
        Temp = Mid(Digits, I + 1, 1) & Mid(Digits, I, 1) & Mid(Digits, I, 1) & Temp 
      Case 8 
        Temp = Mid(Digits, I + 1, 1) & Mid(Digits, I, 1) & Mid(Digits, I, 1) & Mid(Digits, I, 1) & Temp 
      Case 9 
        Temp = Mid(Digits, I, 1) & Mid(Digits, I + 2, 1) & Temp 
    End Select 

    I = I + 2 
  Loop 

  IntegerToRoman = Temp 

End Function 

To make the report more flexible, we'll add a parameter for when to revert to Arabic numerals (in case we need more than ten Roman numerals at some stage when the report gets longer). Let's call that @StartArabic and it will be an integer with the default value of 10. So now our page number expression is simply:

="Page " & Code.PageNumber(Globals!PageNumber, Parameters!StartArabic.Value)


来源:https://stackoverflow.com/questions/13899447/ssrs-page-numbers-in-page-footer

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!