Report Header

Posted by: shweta on 8 September 2017, 1:58 pm EST

  • Posted 8 September 2017, 1:58 pm EST

    Hi,


    How to dispaly Report Header only on the first page?


    Thanks in advance.

  • Replied 8 September 2017, 1:58 pm EST

    Hello Shweta,

    If I understood you correctly you want to display the Header only on the First sheet where as you have multiple sheets in Spread if this is the case then you can Hide the Column and Row header for the corresponding Sheet using ColumnHeaderVisible & RowHeaderVisible properties. Below is the code snippet to execute this,

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
            FpSpread1.Sheets.Count = 5
            Dim i As Integer
            For i = 1 To 4
                FpSpread1.Sheets(i).ColumnHeaderVisible = False
                FpSpread1.Sheets(i).RowHeaderVisible = False
            Next
        End Sub

     In this example you there are 5 sheets there and only first sheet has the Header. Let me know if this doesn't help you.

     

    Thanks,

     

     

     

  • Replied 8 September 2017, 1:58 pm EST

    Shweta.

    I do not have that version to test the issue with, however I came across an earlier thread, while working on this issue. Hope this helps.

    Thanks

  • Replied 8 September 2017, 1:58 pm EST

    Suresh,


    How to achive that, could you please expain with an example.


    Thanks

  • Replied 8 September 2017, 1:58 pm EST

    Shweta,

    You can use 2 PrintSheet in order to achieve the desired behavior. One to print the sheet with Header and 2nd to print the rest of the pages. Also using the PageRange type,  you can specify what pages to print. I have used the below snippet with 4.0.2010.2005 to achieve the desired behavior.

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
            Dim pi As New FarPoint.Win.Spread.PrintInfo
            pi.Preview = True
            pi.PrintType = FarPoint.Win.Spread.PrintType.PageRange
            pi.PageStart = 1
            pi.PageEnd = 1
            pi.Header = "Header"
            FpSpread1.PrintSheet(0)
            FpSpread1.ActiveSheet.PrintInfo = pi
    End Sub
    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
            Dim pi As New FarPoint.Win.Spread.PrintInfo
            pi.Preview = True
            pi.PrintType = FarPoint.Win.Spread.PrintType.PageRange
            pi.PageStart = 2
            pi.PageEnd = 2
            FpSpread1.PrintSheet(0)
            FpSpread1.ActiveSheet.PrintInfo = pi
    End Sub

    Please note in my used example there were only 2 pages.

  • Replied 8 September 2017, 1:58 pm EST

    Hi Deepak,


    Thanks for your reply. Actually i was talking about Report header not about column and row header.


    I have multiple sheets but i want to print report header only on first page.


    Dim PInfo As New FarPoint.Win.Spread.PrintInfo
    PInfo.Header = "header"


    For same kind of issue scotts has replied that the latest version of Spread for Windows Forms, They have added a new event, PrintHeaderFooterArea, which fires for every page before the header/footer is printed. We can use this event and set the Cancel parameter to True when the PageNumber is not 1. But I am using 2.5 Farpoint version of Spread for Windows Forms.


    Please let me know the resolution for this.


    Thanks.

  • Replied 8 September 2017, 1:58 pm EST

    Hi Suresh,


    This you are achiving it through 2 buttons. one for first page and rest of the pages through second button. We can do it with single button?


     


    Thanks.

  • Replied 8 September 2017, 1:58 pm EST

    Shweta,

    As mentioned earlier, I do not have version 2.5 of Spread to test with and earlier provided solution was with version 4.0.2010.2005 of Spread control. In case we use it on one button click event, then that will overwrite the PrintSheet method for first page. I further tested the same using the PrintHeaderFooterArea event of Spread control in version 4.0.2010.2005 to achieve the desired behavior. Private Sub

    FpSpread1_PrintHeaderFooterArea(ByVal sender As Object, ByVal e As FarPoint.Win.Spread.PrintHeaderFooterAreaEventArgs) Handles FpSpread1.PrintHeaderFooterArea
        If e.PageNumber > 1 And e.IsHeader = True Then
             e.Cancel = True
        End If
    End Sub

Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels