Exporting from a Pivot Table

26-12 Web User Interface Developers Guide for Oracle Application Development Framework return new CellFormatnull, background-color:C0C0C0, font-weight:bold; } } return null; }

26.9.4 How to Create Stoplight and Conditional Formatting in a Pivot Table

Stoplight and conditional formatting of the cells in a pivot table are examples of customizing the cell content. For this kind of customization, an application might prompt a user for a high value and a low value to be associated with the stoplight formatting. Generally three colors are used as follow: ■ Values equal to and above the high value are colored green to indicate they have no issues. ■ Values above the low value but below the high value are colored yellow to warn that they are below the high standard. ■ Values at or below the low value are colored red to indicate that they fall below the minimum acceptable level. Figure 26–13 shows data cells with stoplight formatting for minimum, acceptable, and below standards sales for States. Example 26–6 shows code that performs stoplight formatting in a pivot table that does not display totals. If you want to do stoplight formatting for a pivot table that displays totals, then you might want to combine the code from Example 26–5 which addresses rows with totals with the code for stoplight and conditional formatting. Example 26–6 Sample Code for Stoplight and Conditional Formatting public CellFormat getDataFormatDataCellContext cxt { Use low and high values provided by the application. double low = m_rangeValues.getMinimum.doubleValue 100; double high = m_rangeValues.getMaximum.doubleValue 100; CellFormat cellFormat = new CellFormatnull, null, null; Create stoplight format if isStoplightingEnabled { String color = null; Object value = cxt.getValue; if value = null value instanceof Number { double dVal = Numbervalue.doubleValue; if dVal = low { color = background-color: + ColorUtils.colorToHTMLm_belowColor + ;; } else if dVal low dVal = high { color = background-color: + ColorUtils.colorToHTMLm_goodColor + ;; } else if dVal high { color = background-color: + ColorUtils.colorToHTMLm_aboveColor + ;; } Using ADF Pivot Table Components 26-13 } cellFormat.setStylecolor; } return cellFormat; }

26.10 Pivot Table Data Cell Stamping and Editing

The content in a pivot table data cell can be stamped using the dvt:dataCell child component to place a read-only or input component in each data cell. When you use stamping, child components are not created for every data cell in a pivot table. Rather, the content of the dvt:dataCell component is repeatedly rendered, or stamped, once per data attribute, such as the rows in a pivot table. Only certain types of components are supported, including all components with no activity and most components that implement the EditableValueHolder or ActionSource interfaces. You can also use stamping to specify custom CSS styles for the data cell. Each time a child component is stamped, the data for the current cell is copied into a var property used by the data cell component in an EL Expression. Once the pivot table has completed rendering, the var property is removed, or reverted back to its previous value. Data cell editing is enabled by using an input component as the child component of dvt:dataCell. At runtime you can open the cell for editing by double-clicking the cell in the pivot table, or by selecting the cell and pressing F2. Example 26–7 shows sample code for data cell stamping. Example 26–7 Data Cell Stamping Sample Code dvt:pivotTable var=cellData varStatus=cellStatus dvt:dataCell af:switcher defaultFacet=default facetName={cellStatus.members.MeasDim.value} f:facet name=Sales af:inputText value={cellData.dataValue} f:facet f:facet name=Weight af:outputText value={cellData.dataValue} inlineStyle={cellStatus.cellFormat.textStyle} f:facet f:facet name=Available af:selectBooleanCheckbox id=idselectbooleancheckbox label=Availability text=Item Available autoSubmit=true value={cellData.dataValue} f:facet f:facet name=default af:outputText value={cellData.dataValue} f:facet af:switcher dvt:dataCell dvt:pivotTable Figure 26–14 shows the resulting pivot table.