public String header(TableModel model) { StringBuffer sb = new StringBuffer(); Export export = model.getExportHandler().getCurrentExport(); String headerColor = export.getAttributeAsString(HEADER_COLOR); String headerBackgroundColor = export.getAttributeAsString(HEADER_BACKGROUND_COLOR); sb.append(" <fo:table-header background-color=\"" + headerBackgroundColor + "\" color=\"" + headerColor + "\"> "); sb.append(" <fo:table-row> "); List columns = model.getColumnHandler().getHeaderColumns(); for (Iterator iter = columns.iterator(); iter.hasNext();) { Column column = (Column) iter.next(); String title = column.getCellDisplay(); sb.append(" <fo:table-cell border=\"solid silver .5px\" text-align=\"center\" display-align=\"center\" padding=\"3pt\"> "); sb.append(" <fo:block" + getFont() + ">" + title + "</fo:block> "); sb.append(" </fo:table-cell> "); } sb.append(" </fo:table-row> "); sb.append(" </fo:table-header> "); return sb.toString(); }
/** * TWEST - New Method that answers a StringBuffer containing the totals * information. If no totals exist on the model answer an empty buffer. * * The totals row will be given the same style as the header row. * * @param model * @return StringBuffer containing the complete fo statement for totals */ public StringBuffer totals(TableModel model) { StringBuffer sb = new StringBuffer(); Export export = model.getExportHandler().getCurrentExport(); String headerColor = export.getAttributeAsString(HEADER_COLOR); String headerBackgroundColor = export.getAttributeAsString(HEADER_BACKGROUND_COLOR); Column firstCalcColumn = model.getColumnHandler().getFirstCalcColumn(); if (firstCalcColumn != null) { int rows = firstCalcColumn.getCalc().length; for (int i = 0; i < rows; i++) { sb.append("<fo:table-row>"); for (Iterator iter = model.getColumnHandler().getColumns().iterator(); iter.hasNext();) { Column column = (Column) iter.next(); if (column.isFirstColumn()) { String calcTitle = CalcUtils.getFirstCalcColumnTitleByPosition(model, i); sb.append(" <fo:table-cell border=\"solid silver .5px\" text-align=\"center\" display-align=\"center\" padding=\"3pt\" background-color=\""); sb.append(headerBackgroundColor + "\" color=\"" + headerColor + "\">"); sb.append(" <fo:block " + getFont() + ">" + calcTitle); sb.append(" </fo:block></fo:table-cell> "); continue; } if (column.isCalculated()) { sb.append(" <fo:table-cell border=\"solid silver .5px\" text-align=\"center\" display-align=\"center\" padding=\"3pt\" background-color=\""); sb.append(headerBackgroundColor + "\" color=\"" + headerColor + "\"> "); sb.append(" <fo:block " + getFont() + ">"); CalcResult calcResult = CalcUtils.getCalcResultsByPosition(model, column, i); Number value = calcResult.getValue(); if (value != null) { sb.append(ExtremeUtils.formatNumber(column.getFormat(), value, model.getLocale())); } else { sb.append("n/a"); } sb.append("</fo:block> "); } else { sb.append(" <fo:table-cell border=\"solid silver .5px\" text-align=\"center\" display-align=\"center\" padding=\"3pt\" background-color=\""); sb.append(headerBackgroundColor + "\" color=\"" + headerColor + "\"> "); sb.append(" <fo:block " + getFont() + ">"); sb.append(" "); sb.append("</fo:block> "); } sb.append(" </fo:table-cell> "); } sb.append("</fo:table-row>"); } } return sb; }
public String regionBefore(TableModel model) { StringBuffer sb = new StringBuffer(); Export export = model.getExportHandler().getCurrentExport(); String headerBackgroundColor = export.getAttributeAsString(HEADER_BACKGROUND_COLOR); sb.append(" <fo:static-content flow-name=\"xsl-region-before\"> "); String title = export.getAttributeAsString(HEADER_TITLE); sb.append(" <fo:block space-after.optimum=\"15pt\" color=\"" + headerBackgroundColor + "\" font-size=\"17pt\" font-family=\"" + getHeadFont() + "'Times'\">" + title + "</fo:block> "); sb.append(" </fo:static-content> "); return sb.toString(); }