public void body(TableModel model, Column column) { if (column.isFirstColumn()) { rownum++; cellnum = 0; hssfRow = sheet.createRow(rownum); } String value = column.getCellDisplay(); if (StringUtils.isNumeric(value)) { value = column.getValue() == null ? "" : column.getValue().toString(); } value = value.replaceAll("\t", "").replaceAll("\n", ""); value = ExportViewUtils.parseXLS(value); HSSFCell hssfCell = hssfRow.createCell(cellnum); // modify by springside // hssfCell.setEncoding(HSSFCell.ENCODING_UTF_16); // end of modify by springside if (column.isEscapeAutoFormat()) { writeToCellAsText(hssfCell, value); } else { writeToCellFormatted(hssfCell, value); } cellnum++; }
/** * 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 void body(TableModel model, Column column) { if (column.isFirstColumn()) { xlsfo.append(" <fo:table-row> "); } String value = ExportViewUtils.parsePDF(column.getCellDisplay()); xlsfo.append(" <fo:table-cell border=\"solid silver .5px\" display-align=\"center\" padding=\"3pt\"> "); xlsfo.append(" <fo:block" + getFont() + ">" + value + "</fo:block> "); xlsfo.append(" </fo:table-cell> "); if (column.isLastColumn()) { xlsfo.append(" </fo:table-row> "); } }