ArrayList<Column> columns = getShownColumns(); for ( Column column : columns ) { TableColumn tableColumn = new TableColumn( table, column.getStyle() ); tableColumn.setText( column.getTitle() ); tableColumn.setWidth( column.getWidth() ); }
//Instantiating a Workbook object Workbook workbook = new Workbook(); //Accessing the added worksheet in the Excel file int sheetIndex = workbook.getWorksheets().add(); Worksheet worksheet = workbook.getWorksheets().get(sheetIndex); Cells cells = worksheet.getCells(); Column column = cells.getColumns().get(30); Style style1 = column.getStyle(); style1.setHorizontalAlignment(TextAlignmentType.CENTER); style1.setCustom("$#,##0;[Red]$-#,##0"); StyleFlag styleFlag1 = new StyleFlag(); styleFlag1.setNumberFormat(true); styleFlag1.setHorizontalAlignment(true); //Applying the style to the column column.applyStyle(style1, styleFlag1); //Saving the modified Excel file in default format workbook.save("C:\\output.xls");
for (int j = 0; j < columns.size(); j++) { Column column = columns.get(j); String style = column.getStyle(); String styleClass = column.getStyleClass();
@Override public void encode(FacesContext context, Column column) throws IOException { ResponseWriter writer = context.getResponseWriter(); String style = column.getStyle(); String styleClass = column.getStyleClass(); styleClass = (styleClass == null) ? PanelGrid.CELL_CLASS : PanelGrid.CELL_CLASS + " " + styleClass; writer.startElement("td", null); writer.writeAttribute("role", "gridcell", null); writer.writeAttribute("class", styleClass, null); if (style != null) { writer.writeAttribute("style", style, null); } if (column.getColspan() > 1) { writer.writeAttribute("colspan", column.getColspan(), null); } if (column.getRowspan() > 1) { writer.writeAttribute("rowspan", column.getRowspan(), null); } renderChildren(context, column); writer.endElement("td"); }
@Override public void encode(FacesContext context, Column column) throws IOException { ResponseWriter writer = context.getResponseWriter(); String style = column.getStyle(); String styleClass = column.getStyleClass(); String defaultStyleClass = PanelGrid.CELL_CLASS + " ui-widget-header"; styleClass = (styleClass == null) ? defaultStyleClass : defaultStyleClass + " " + styleClass; writer.startElement("td", null); writer.writeAttribute("role", "columnheader", null); writer.writeAttribute("class", styleClass, null); if (style != null) { writer.writeAttribute("style", style, null); } if (column.getColspan() > 1) { writer.writeAttribute("colspan", column.getColspan(), null); } if (column.getRowspan() > 1) { writer.writeAttribute("rowspan", column.getRowspan(), null); } renderChildren(context, column); writer.endElement("td"); }
public void encodeRow(FacesContext context, SubTable table, int rowIndex) throws IOException { table.setRowIndex(rowIndex); if (!table.isRowAvailable()) { return; } ResponseWriter writer = context.getResponseWriter(); String clientId = table.getClientId(context); writer.startElement("tr", null); writer.writeAttribute("id", clientId + "_row_" + rowIndex, null); writer.writeAttribute("class", DataTable.ROW_CLASS, null); for (Column column : table.getColumns()) { String style = column.getStyle(); String styleClass = column.getStyleClass(); writer.startElement("td", null); if (style != null) { writer.writeAttribute("style", style, null); } if (styleClass != null) { writer.writeAttribute("class", styleClass, null); } column.encodeAll(context); writer.endElement("td"); } writer.endElement("tr"); }
protected void encodeFacetColumn(FacesContext context, SubTable table, Column column, String facetName, String styleClass, String text) throws IOException { if (!column.isRendered()) { return; } ResponseWriter writer = context.getResponseWriter(); String style = column.getStyle(); String columnClass = column.getStyleClass(); columnClass = (columnClass == null) ? styleClass : styleClass + " " + columnClass; writer.startElement("td", null); writer.writeAttribute("class", columnClass, null); if (column.getRowspan() != 1) { writer.writeAttribute("rowspan", column.getRowspan(), null); } if (column.getColspan() != 1) { writer.writeAttribute("colspan", column.getColspan(), null); } if (style != null) { writer.writeAttribute("style", style, null); } // Footer content UIComponent facet = column.getFacet(facetName); if (facet != null) { facet.encodeAll(context); } else if (text != null) { writer.write(text); } writer.endElement("td"); }
@Override public void encodeEnd(FacesContext context, UIComponent component) throws IOException { SummaryRow row = (SummaryRow) component; ResponseWriter writer = context.getResponseWriter(); writer.startElement("tr", null); writer.writeAttribute("class", DataTable.SUMMARY_ROW_CLASS, null); for (UIComponent kid : row.getChildren()) { if (kid.isRendered() && kid instanceof Column) { Column column = (Column) kid; String style = column.getStyle(); String styleClass = column.getStyleClass(); writer.startElement("td", null); if (style != null) { writer.writeAttribute("style", style, null); } if (styleClass != null) { writer.writeAttribute("class", styleClass, null); } if (column.getRowspan() != 1) { writer.writeAttribute("rowspan", column.getRowspan(), null); } if (column.getColspan() != 1) { writer.writeAttribute("colspan", column.getColspan(), null); } column.encodeAll(context); writer.endElement("td"); } } writer.endElement("tr"); }
if (child.isRendered() && child instanceof Column) { Column column = (Column) child; String style = column.getStyle(); String styleClass = column.getStyleClass();
String style = ((Column) child).getStyle(); String styleClass = ((Column) child).getStyleClass();
public void encode(FacesContext context, Column column) throws IOException { ResponseWriter writer = context.getResponseWriter(); String style = column.getStyle(); String styleClass = column.getStyleClass(); styleClass = (styleClass == null) ? PanelGrid.CELL_CLASS : PanelGrid.CELL_CLASS + " " + styleClass; writer.startElement("td", null); writer.writeAttribute("role", "gridcell", null); writer.writeAttribute("class", styleClass, null); if (style != null) writer.writeAttribute("style", style, null); if (column.getColspan() > 1) writer.writeAttribute("colspan", column.getColspan(), null); if (column.getRowspan() > 1) writer.writeAttribute("rowspan", column.getRowspan(), null); renderChildren(context, column); writer.endElement("td"); }
public void encode(FacesContext context, Column column) throws IOException { ResponseWriter writer = context.getResponseWriter(); String style = column.getStyle(); String styleClass = column.getStyleClass(); String defaultStyleClass = PanelGrid.CELL_CLASS + " ui-widget-header"; styleClass = (styleClass == null) ? defaultStyleClass : defaultStyleClass + " " + styleClass; writer.startElement("td", null); writer.writeAttribute("role", "columnheader", null); writer.writeAttribute("class", styleClass, null); if (style != null) writer.writeAttribute("style", style, null); if (column.getColspan() > 1) writer.writeAttribute("colspan", column.getColspan(), null); if (column.getRowspan() > 1) writer.writeAttribute("rowspan", column.getRowspan(), null); renderChildren(context, column); writer.endElement("td"); }
public void encodeRow(FacesContext context, SubTable table, int rowIndex) throws IOException { table.setRowIndex(rowIndex); if (!table.isRowAvailable()) { return; } ResponseWriter writer = context.getResponseWriter(); String clientId = table.getClientId(context); writer.startElement("tr", null); writer.writeAttribute("id", clientId + "_row_" + rowIndex, null); writer.writeAttribute("class", DataTable.ROW_CLASS, null); for (Column column : table.getColumns()) { String style = column.getStyle(); String styleClass = column.getStyleClass(); writer.startElement("td", null); if (style != null) writer.writeAttribute("style", style, null); if (styleClass != null) writer.writeAttribute("class", styleClass, null); column.encodeAll(context); writer.endElement("td"); } writer.endElement("tr"); }
protected void encodeFacetColumn(FacesContext context, SubTable table, Column column, String facetName, String styleClass, String text) throws IOException { if (!column.isRendered()) { return; } ResponseWriter writer = context.getResponseWriter(); String style = column.getStyle(); String columnClass = column.getStyleClass(); columnClass = (columnClass == null) ? styleClass : styleClass + " " + columnClass; writer.startElement("td", null); writer.writeAttribute("class", columnClass, null); if (column.getRowspan() != 1) writer.writeAttribute("rowspan", column.getRowspan(), null); if (column.getColspan() != 1) writer.writeAttribute("colspan", column.getColspan(), null); if (style != null) writer.writeAttribute("style", style, null); // Footer content UIComponent facet = column.getFacet(facetName); if (facet != null) { facet.encodeAll(context); } else if (text != null) { writer.write(text); } writer.endElement("td"); }
@Override public void encodeEnd(FacesContext context, UIComponent component) throws IOException { SummaryRow row = (SummaryRow) component; ResponseWriter writer = context.getResponseWriter(); writer.startElement("tr", null); writer.writeAttribute("class", DataTable.SUMMARY_ROW_CLASS, null); for (UIComponent kid : row.getChildren()) { if (kid.isRendered() && kid instanceof Column) { Column column = (Column) kid; String style = column.getStyle(); String styleClass = column.getStyleClass(); writer.startElement("td", null); if (style != null) writer.writeAttribute("style", style, null); if (styleClass != null) writer.writeAttribute("class", styleClass, null); if (column.getRowspan() != 1) writer.writeAttribute("rowspan", column.getRowspan(), null); if (column.getColspan() != 1) writer.writeAttribute("colspan", column.getColspan(), null); column.encodeAll(context); writer.endElement("td"); } } writer.endElement("tr"); }