FlexReport Page Footer Expressions

Posted by: ahmdsalh on 11 January 2018, 2:00 am EST

    • Post Options:
    • Link

    Posted 11 January 2018, 2:00 am EST

    Hi,

    I’m new in using C1FlexReport.

    I’m trying to create report layout using VB.Net code according to the tutorial in the documentation as well as other info from the form here.

    Till now everything is going fine in creating sections, adding fields, etc.

    However, i can’t use the expressions in the page footer. i want to add for example date, time ( NOW() ), page number and pages, etc and all other similar suff.

    when i use txtField.Text.Expression = “Printed on &Now” (or “Printed on & Now” or even “Printed on Now()”) , the field become blank when i render the report.

    so, 1) How can i fix this?

    2) What are the available expressions that are available in the flexreport?

    P.S.: the tutorial code in the documentation doesn’t work at all for the expressions

    here is the code in the documentation tutorial

    textFld2.Text.Expression = “”

    “Employees: Printed on "

    " & Now”

    actually, how these 3 lines are even possible without concatenation?!

    Thanks in Advance.

  • Posted 11 January 2018, 9:05 pm EST

    Hello Ahmed,

    You can use the below mentioned expressions for adding Date, Time and Page/Pages, respectively:

                dt.Text.Expression=" \"Printed On:\"+ Format(Now, \"Medium Date\")"
    
    ```[b]Result:[/b] Printed On:12-Jan-18
    
    
            tm.Text.Expression=" \"Printed On:\"+ Format(Now, \"Medium Time\")"
    
    
    
            pageOfPages.Text.Expression ="\"Page \" & [Page] & \" of \" & [Pages]"
    
    This can help you get rid of the blank spaces.
    Please note that you can use the expressions from the designer, in code just by ensuring that you are escaping the double quotes at the necessary places. 
    
    There exists no general list of the supported expressions. However, you can let us know if you face any issue while using an expression and we will be happy to help you. 
    Also, can you help us by sharing the documentation link of the tutorial you referred? This will help us assist you efficiently.
    
    Best Regards,
    Esha
  • Posted 11 January 2018, 10:48 pm EST

    Thanks for your quick reply:

    1- It worked fine (just i escape " using double quotation i.e. “” not " )

    2- The tutorial mistake is on page 38 in the documentation (just put all the three lines mentioned above in a single line without spaces.

    3- Now the layout of the report is working fine. However the data itself is not loaded into the details section. i tried many many things and nothing works, the Detail Section never loads.

    would you please tell me what am i doing wrong?

    
            With C1FlexReport1
    
                .DataSource.RecordSourceType = FlexReport.RecordSourceType.Auto
    
                ' clear any existing fields  
                .Clear()
    
                ' set default font for all controls
                .Font.Name = "Tahoma"
                .Font.Size = 8
    
                'initialize DataSources
                 Dim ds As Data.DataSet = getDataSet()
                .DataSource.Recordset = ds.Tables(0)
    
                'initialize Layout
                Dim objLayout As FlexReport.Layout
                objLayout = C1FlexReport1.Layout
                With objLayout
                    .Orientation = FlexReport.OrientationEnum.Portrait
                    .Width = 6.5 * 1440 ' 8.5 - margins, In twips
                End With
    
    
                'Create a Page header   
                Dim objSectionPageHeader As FlexReport.Section
                objSectionPageHeader = C1FlexReport1.Sections(FlexReport.SectionTypeEnum.PageHeader)
                With objSectionPageHeader
                    .Height = 500
                    .Visible = True
                End With
    
                'Add Fields To PageHeader
                Dim textFld4 As New FlexReport.TextField
                With textFld4
                    .Name = "LblID"
                    .Text = "Workspace ID"
                    .Left = 0 : .Top = 50: .Width = 1400 : .Height = 300
                    .Align = FlexReport.FieldAlignEnum.RightTop
                End With
                'Add the field to the appropriate section
                .Sections.PageHeader.Fields.Add(textFld4)
    
                'Create the Details Section  
                Dim objSectionDetails As FlexReport.Section
                objSectionDetails = C1FlexReport1.Sections(FlexReport.SectionTypeEnum.Detail)
                With objSectionPageHeader
                    .Height = 330
                    .Visible = True
                End With
    
                'Add Fields To Details
                Dim textFld5 As New FlexReport.TextField
                With textFld5
                    .Name = "FldID"
                    .Text.Expression = "Workspace_PK"
                    .Left = 0 : .Top = 50
                    .Width = 1400 : .Height = 300
                    .Visible = True
                End With
                'Add the field to the appropriate section
                .Sections.Detail.Fields.Add(textFld5)
    
    
                    ''RENDER THE REPORT
                    .Render()
    
                    ''SET THE VIWER DOCUMENT SOURCE
                    C1FlexViewer1.DocumentSource = C1FlexReport1
    
            End With
    
    
  • Posted 11 January 2018, 10:54 pm EST

    P.S. i’m using datatable that gets data from a SQL Server then i pass the datatable as a record set to the flexreport.

  • Posted 12 January 2018, 6:19 pm EST

    I’m sorry, i figured it out … the error was in the detail section visibility.

    Please ignore the last part of this post

  • Posted 14 January 2018, 6:05 pm EST

    Hello Ahmed,

    Thanks for sharing the documentation reference.

    As you mentioned, the three lines should actually be in a single line. This is represented in the documentation separately for understanding purpose.

    Thanks,

    Esha

Need extra support?

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

Learn More

Forum Channels