Using Selection in Pivot Tables

Using ADF Pivot Table Components 26-9 Figure 26–12 Pivot Table Export to Excel Spreadsheet

26.9 Customizing the Cell Content of a Pivot Table

All cells in a pivot table are either header cells or data cells. Before rendering a cell, the pivot table calls a method expression. You can customize the content of pivot table header cells and data cells by providing method expressions for the following attributes of the dvt:pivotTable tag: ■ For header cells, use one of the following attributes: – headerFormat: Use to create formatting rules to customize header cell content. – headerFormatManager: Use only if you want to provide custom state saving for the formatting rules of the application’s pivot table header cells. ■ For data cells, use one of the following attributes: – dataFormat: Use to create formatting rules to customize data cell content. – dataFormatManager: Use only if you want to provide custom state saving for the formatting rules of the application’s pivot table data cells.

26.9.1 How to Create a CellFormat Object for a Data Cell

To specify customization of the content of a data cell, you must code a method expression that returns an instance of oracle.dss.adf.view.faces.bi.component.pivotTable.CellFormat. To create an instance of a CellFormat object for a data cell: 1. Construct an oracle.adf.view.faces.bi.component.pivotTable.DataCellContext object for the data cells that you want to format. The DataCellContext method requires the following parameters in its constructor: – model: The name of the dataModel used by the pivot table. – row: An integer that specifies the zero-based row that contains the data cell on which you are operating. Note: You may receive a warning from Excel stating that the file is in a different format than specified by the file extension. This warning can be safely ignored. 26-10 Web User Interface Developers Guide for Oracle Application Development Framework – column: An integer that specifies the zero-based column that contains the data cell that you want to format. – qdr: The QDR that is a fully qualified reference for the data cell that you want to format. – value: A java.lang.Object that contains the value in the data cell that you want to format. 2. Pass the DataCellContext to a method expression for the dataFormat attribute of the pivot table. 3. In the method expression, write code that specifies the kind of formatting you want to apply to the data cells of the pivot table. This method expression must return a CellFormat object.

26.9.2 How to Construct a CellFormat Object

An instance of a CellFormat object lets you specify the following arguments: ■ Converter: An instance of javax.faces.convert.Converter, which is used to perform number, date, or text formatting of a raw value in a cell. ■ CSS style: Used to change the CSS style of a cell. For example, you might use this argument to change the background color of a cell. ■ CSS text style: Used to change the CSS style of the text in a cell. For example, you might use this argument to set text to bold. ■ New raw value: Used to change the cell’s underlying value that was returned from the data model. For example, you might choose to change the abbreviated names of states to longer names. In this case, the abbreviation NY might be changed to New York.

26.9.3 How to Change Format and Text Styles

You can apply formatting and text styles to emphasize aspects of the data displayed in the pivot table. Figure 26–13 shows a pivot table with sales totals generated for products and for product categories. In the rows that contain totals, this pivot table displays bold text a text style change against a shaded background a style change. These changes show in both the row header cells and the data cells for the pivot table. The row headers for totals contain the text Sales Total. The pivot table also shows stoplight and conditional formatting of data cells. For more information, see Section 26.9.4, How to Create Stoplight and Conditional Formatting in a Pivot Table.