Skip to main content
A newer version of this page is available. .

Create a Vertical Report

  • 5 minutes to read

This tutorial describes how to use vertical bands to create a Profit and Loss report in Visual Studio at design time. Follow the steps below to create a report based on the Profit and Loss demo that comes with the DevExpress Demo Center.

Tip

To get started with this tutorial, open an existing reporting application or create a new application (the Add a Report to Your .NET Application section explains how to create a reporting application on different platforms).

Add a Demo Data Source

The Profit and Loss demo uses the Data business class that generates field values randomly. You should copy the Data.cs/Data.vb file with this class from the C:\Users\Public\Documents\DevExpress Demos 19.1\Components\Reporting\CS\DevExpress.DemoReports\ProfitAndLossReport folder to your project to use this tutorial.

VerticalBandDemoReport_Project

You can apply the HighlightedClass attribute to the Data class to distinguish it from other classes in the Report Wizard.

// Ensure a reference to the DevExpress.DataAccess assembly is added to the project
using DevExpress.DataAccess.ObjectBinding;
//...
[HighlightedClass]
public class Data {
    public DateTime Month { get; set; }
    //...
}

Build your solution.

Add a Vertical Report

Invoke the Report Wizard.

  1. Select Vertical Report and click Next.

    VerticalBandDemoReport_SelectReportType

  2. (2.1-2.6) Set the report’s data source to the Data class that you added in previous steps.

  3. Select the data fields that should be included in the report.

    VerticalBandDemoReport_SelectFields

  4. Specify group data fields to create a report with grouped data (the report in this tutorial does not have group fields).

  5. Add summary fields to the report.

    VerticalBandDemoReport_SummaryFunctions

  6. Change the report page layout to landscape so that the vertical table fit the report.

    VerticalBandDemoReport_PageSettings

  7. You can set the report’s color scheme.

    VerticalBandDemoReport_ColorScheme

  8. Specify the Profit and Loss title.

    VerticalBandDemoReport_Title

Click Finish and the generated report opens in the Report Designer.

VerticalBandDemoReport_WizardResult

The wizard adds report controls to the following bands:

  • Vertical Header band
    Contains a table with a single column that displays headers of the report’s data fields.
  • Vertical Details band
    Contains a table with a single column that is printed so many times as there are records in the report’s data source.
  • Vertical Total band
    Contains a table with a single column that has so many labels in cells as there are summary functions you specified for each field in the Report Wizard (only the sum function for each field in this demo).

Switch to the Preview tab to see an intermediate result.

VerticalBandDemoReport_WizardResult

Tip

You can create a vertical report without using the Report Wizard. Right-click the report in the Report Designer and choose Insert Vertical Band in the invoked context menu. Refer to the Introduction to Banded Reports topic for more information.

Set up the Vertical Header Band

Perform the following modifications in the Vertical Header band:

VerticalBandDemoReport_VerticalHeader_Result

  1. Remove the Month field’s header.
    Reset the cell’s Text property.

  2. Add extra cells to the table’s column to display group names for data fields.

  3. Add cells to the table’s column to display headers for vertical totals.

  4. Set the data field headers’ Padding.Left property to 42.

  5. Assign the HeaderData1Vertical style to all the cells in the Vertical Header band.

Set up the Vertical Detail Band

Perform the following modifications in the Vertical Detail band:

VerticalBandDemoReport_VerticalDetailBand

  1. Set the Month field-bound cell’s Expression property to Upper(FormatString(‘{0:MMM}’, [Month])) and the TextAlignment property to MiddleRight.

    VerticalBandDemoReport_MonthExpression

  2. Add cells corresponding to the extra cells you added in the Vertical Header band.

  3. Add calculated fields and bind the corresponding cells to them.

    VerticalBandDemoReport_AddCalculatedField

  4. Select all the data-bound cells and set their Format String property to {0:C2} (the default value that the wizard set for decimal fields).

    VerticalBandDemoReport_CalculatedFields_Format

  5. Assign styles to the Vertical Detail band’s cells:

    • the HeaderData1Vertical style - to the empty and the Month cells;
    • the DetailData1Vertical style - to the cells bound to the data source fields;
    • the TotalData1Vertical style - to the cells bound to the calculated fields.

Set up the Vertical Total Band

Perform the following modifications in the Vertical Total band:

VerticalBandDemoReport_VerticalTotalBand

  1. Set the first cell’s Text property to TOTAL.

  2. Add cells corresponding to the extra cells you added in the Vertical Header band.

  3. Add labels to display vertical totals that summarize totals in each group.
    Copy and paste a label with a total function so that all totals have the same size and position. Specify the Expression and Format String properties for the added labels.

    VerticalBandDemoReport_VerticalDetailBand

  4. Assign styles to the Vertical Total band’s cells:

    • the HeaderData1Vertical style - to the empty and the TOTAL cells;
    • the TotalData1Vertical style - to the cells with summary functions.

Preview the Result

Switch to the preview tab and see the result.

Set Vertical Table Options

You can set the following options to modify the vertical table:

  • Set the Vertical Header band’s RepeatEveryPage property to false to display field headers once - on the first report page.

  • Set the Vertical Detail band’s BandLayout property to AcrossThenDown to print the data records that do not fit a page on the same page, otherwise, they are printed on the next page (as in this demo).

  • Specify the Vertical Detail band’s SortFields property to sort the report’s data.