List of usage examples for org.apache.poi.xwpf.usermodel XWPFTableCell setVerticalAlignment
public void setVerticalAlignment(XWPFVertAlign vAlign)
From source file:csv2docxconverter.DocumentGenerator.java
/** * Set header cell style/* w w w . j a v a 2s . c o m*/ */ private XWPFRun setHeaderCell(XWPFTableCell cell) { cell.setVerticalAlignment(XWPFTableCell.XWPFVertAlign.CENTER); XWPFParagraph paragraph = cell.getParagraphArray(0); paragraph.setAlignment(ParagraphAlignment.CENTER); paragraph.setSpacingBefore(8); paragraph.setSpacingAfter(8); XWPFRun run = paragraph.createRun(); run.setBold(true); return run; }
From source file:csv2docxconverter.DocumentGenerator.java
/** * Set body cell style//ww w . j a va 2 s .c o m */ private XWPFRun setBodyCell(XWPFTableCell cell) { cell.setVerticalAlignment(XWPFTableCell.XWPFVertAlign.CENTER); XWPFParagraph paragraph = cell.getParagraphArray(0); paragraph.setAlignment(ParagraphAlignment.CENTER); paragraph.setSpacingBefore(4); paragraph.setSpacingAfter(4); return paragraph.createRun(); }
From source file:de.knowwe.include.export.TableExporter.java
License:Open Source License
@Override public void export(Section<WikiTable> section, DocumentBuilder manager) throws ExportException { // initialize table for easier access Matrix<Section<TableCell>> matrix = toMatrix(section); // create table with correct dimension XWPFDocument doc = manager.getDocument(); XWPFTable table = doc.createTable(matrix.getRowSize(), matrix.getColSize()); boolean headerCellsOnly = true; for (int row = 0; row < matrix.getRowSize(); row++) { XWPFTableRow tableRow = table.getRow(row); for (int col = 0; col < matrix.getColSize(); col++) { Section<TableCell> cell = matrix.get(row, col); boolean isHeader = cell.get().isHeader(cell); boolean isZebra = row % 2 == 0; headerCellsOnly &= isHeader; // prepare cell shading XWPFTableCell tableCell = tableRow.getCell(col); CTShd shade = tableCell.getCTTc().addNewTcPr().addNewShd(); if (isHeader) { shade.setFill("D0D0D0"); tableCell.setVerticalAlignment(XWPFTableCell.XWPFVertAlign.CENTER); } else if (isZebra) { shade.setFill("F2F2F2"); }//from w w w. j a va 2 s .c om // fill cell contents DocumentBuilder cellBuilder = new CellBuilder(manager, tableCell, isHeader); Section<?> content = Sections.successor(cell, ParagraphTypeForLists.class); if (content != null) { cellBuilder.export(content); } // clean trailing white-spaces of each cell List<CTR> runs = cellBuilder.getParagraph().getCTP().getRList(); if (runs.isEmpty()) continue; CTR ctr = runs.get(runs.size() - 1); List<CTText> texts = ctr.getTList(); if (texts.isEmpty()) continue; CTText ctText = texts.get(texts.size() - 1); ctText.setStringValue(Strings.trimRight(ctText.getStringValue())); } // check if the first row(s) have only headers, // repeat those headers until a non-header cell has come if (headerCellsOnly) { tableRow.setRepeatHeader(true); } tableRow.setCantSplitRow(true); } // append empty line after each table manager.closeParagraph(); manager.append("\n\r"); manager.closeParagraph(); }
From source file:edu.gatech.pmase.capstone.awesome.impl.output.DisasterResponseTradeStudyOutputer.java
License:Open Source License
/** * Creates the architecture result table. * * @param result the top architecture result. * @param table the table to create the architecture in *///from w w w .j a v a2 s . c o m private void createArchTable(final DRTSArchitectureResult result, final XWPFTable table) { final XWPFTableCell platLabel = table.getRow(1).getCell(0); platLabel.setVerticalAlignment(XWPFTableCell.XWPFVertAlign.CENTER); final XWPFTableCell commLabel = table.getRow(2).getCell(0); commLabel.setVerticalAlignment(XWPFTableCell.XWPFVertAlign.CENTER); final XWPFTableCell sensorLabel = table.getRow(3).getCell(0); sensorLabel.setVerticalAlignment(XWPFTableCell.XWPFVertAlign.CENTER); if (null != result) { LOGGER.debug("Adding architecture result to output file: " + result.toString()); platLabel.setText(result.getPlatform().getLabel()); final XWPFTableCell platDetails = table.getRow(1).getCell(2); platDetails.setVerticalAlignment(XWPFTableCell.XWPFVertAlign.CENTER); this.createArchitectureAttributeDescription(platDetails, result.getPlatform().getPrioritizationAttributess()); commLabel.setText(result.getComms().getLabel()); final XWPFTableCell commDetails = table.getRow(2).getCell(2); commDetails.setVerticalAlignment(XWPFTableCell.XWPFVertAlign.CENTER); this.createArchitectureAttributeDescription(commDetails, result.getComms().getPrioritizationAttributess()); sensorLabel.setText(result.getSensor().getLabel()); final XWPFTableCell sensorDetails = table.getRow(3).getCell(2); sensorDetails.setVerticalAlignment(XWPFTableCell.XWPFVertAlign.CENTER); this.createArchitectureAttributeDescription(sensorDetails, result.getSensor().getPrioritizationAttributess()); } else { LOGGER.debug("No result found, cannot create architecture options"); DisasterResponseTradeStudyOutputer.createNoOptionText(platLabel, "Platform"); DisasterResponseTradeStudyOutputer.createNoOptionText(commLabel, "Communications Option"); DisasterResponseTradeStudyOutputer.createNoOptionText(sensorLabel, "Sensor Option"); } }
From source file:edu.gatech.pmase.capstone.awesome.impl.output.DisasterResponseTradeStudyOutputer.java
License:Open Source License
/** * Creates the selected disaster effects table. * * @param selectedDisasterEffects the disaster effects selected by the user. * @param table the table to write the selected disaster effects to *//* w w w . j a va 2s . co m*/ private void createSelectedDisasterTable(final List<DisasterEffect> selectedDisasterEffects, final XWPFTable table) { for (final DisasterEffect effect : selectedDisasterEffects) { final Integer index = disEffectColsMap.get(effect); if (null != index) { LOGGER.debug( "Adding DisasterEffect " + effect.name() + " to result document at table index: " + index); final XWPFTableCell effectIndicatorCell = table.getRow(index).getCell(1); effectIndicatorCell.setVerticalAlignment(XWPFTableCell.XWPFVertAlign.CENTER); effectIndicatorCell.setText(CHECKMARK_UNICODE); } else { LOGGER.warn("Could not find index to place DisasterEffect: " + effect.name() + " in output file."); } } }
From source file:edu.gatech.pmase.capstone.awesome.impl.output.DisasterResponseTradeStudyOutputer.java
License:Open Source License
/** * Creates the terrain effects table./* www .ja v a2s . co m*/ * * @param selectedTerrainEffects the terrain effects selected but the user * @param table the table to write the terrain effects in. */ private void createSelectedTerrainTable(final List<TerrainEffect> selectedTerrainEffects, final XWPFTable table) { for (final TerrainEffect eff : selectedTerrainEffects) { final Integer index = terEffectColsMap.get(eff.terrainLabel); if (null != index) { LOGGER.debug("Adding TerrainEffect " + eff.name() + " to result document at table index: " + index); final XWPFTableCell effectValueCell = table.getRow(index).getCell(1); effectValueCell.setVerticalAlignment(XWPFTableCell.XWPFVertAlign.CENTER); effectValueCell.setText(Integer.toString(eff.codeNum)); final XWPFTableCell effectDescCell = table.getRow(index).getCell(2); effectDescCell.setVerticalAlignment(XWPFTableCell.XWPFVertAlign.CENTER); effectDescCell.setText(eff.codeMeaning); } else { LOGGER.warn("Could not find index to place TerrainEffect: " + eff.name() + " in output file."); } } }
From source file:edu.gatech.pmase.capstone.awesome.impl.output.DisasterResponseTradeStudyOutputer.java
License:Open Source License
/** * Creates an options weighting table for the provided option. * * @param option the option to create the table for * @param table the table to create the option in *//*from w w w. ja va 2 s . com*/ private void createOptionWeightingTable(final AbstractArchitectureOption option, final XWPFTable table) { LOGGER.debug("Adding architeacture option weighting table for option: " + option.getLabel()); for (final ArchitectureOptionAttribute attr : option.getPrioritizationAttributess()) { LOGGER.debug("Adding architeacture option weighting value: " + attr.getLabel() + " with priority value: " + Double.toString(attr.getPriority())); LOGGER.debug(attr.toString()); final XWPFTableRow row = table.createRow(); final XWPFTableCell attrLabel = row.getCell(0); attrLabel.setVerticalAlignment(XWPFTableCell.XWPFVertAlign.CENTER); attrLabel.setText(attr.getLabel() + " (" + attr.getUnits() + ")"); final XWPFTableCell attrWeighting = row.getCell(1); attrWeighting.setVerticalAlignment(XWPFTableCell.XWPFVertAlign.CENTER); attrWeighting.setText(weightingFormat.format(attr.getPriority() * 100.00) + "%"); final CTTcPr pr = attrWeighting.getCTTc().addNewTcPr(); final CTVerticalJc alng = pr.addNewVAlign(); alng.setVal(STVerticalJc.BOTH); } }