List of usage examples for org.apache.poi.xwpf.usermodel XWPFParagraph setSpacingBefore
public void setSpacingBefore(int spaces)
From source file:com.bxf.hradmin.testgen.service.impl.DocxTestGenerator.java
License:Open Source License
private void adjustLineHeight(XWPFParagraph paragraph) { // ??/*from w w w . j a v a2s .c o m*/ paragraph.setSpacingAfter(0); paragraph.setSpacingBefore(0); // ? CTSpacing spacing = paragraph.getCTP().getPPr().getSpacing(); spacing.setLineRule(STLineSpacingRule.EXACT); spacing.setLine(BigInteger.valueOf(360)); }
From source file:csv2docxconverter.DocumentGenerator.java
/** * Set header cell style//from w ww .j a v a 2s. c om */ 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//w w w . j a v a 2s .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:export.TableFunctionalReq.java
protected static void createReqFuncTable(XWPFDocument doc, FunctionalRequirement funcReq) { int[] cols = { 2943, 6507 }; XWPFTable rf = doc.createTable(9, 2); // Get a list of the rows in the table List<XWPFTableRow> rows = rf.getRows(); int rowCt = 0; int colCt = 0; for (XWPFTableRow row : rows) { // get the cells in this row List<XWPFTableCell> cells = row.getTableCells(); for (XWPFTableCell cell : cells) { // get a table cell properties element (tcPr) CTTcPr tcpr = cell.getCTTc().addNewTcPr(); // create cell color element CTShd ctshd = tcpr.addNewShd(); ctshd.setColor("auto"); ctshd.setVal(STShd.CLEAR);//from w ww .j a va2 s . c o m if (colCt == 0) { ctshd.setFill("5C7F92"); } // get 1st paragraph in cell's paragraph list XWPFParagraph para = cell.getParagraphs().get(0); para.setStyle("AltranNormal"); para.setSpacingAfter(120); para.setSpacingBefore(120); // create a run to contain the content XWPFRun rh = para.createRun(); //rh.setFontSize(11); rh.setFontFamily("Lucida Sans Unicode"); if (colCt == 0) { rh.setColor("FFFFFF"); } if (rowCt == 0 && colCt == 0) { rh.setText("RF " + ((x < 9) ? "0" + x : x) + "- F"); x++; } else if (rowCt == 1 && colCt == 0) { rh.setText("Use Case (se disponvel):"); } else if (rowCt == 2 && colCt == 0) { rh.setText("Descrio:"); } else if (rowCt == 3 && colCt == 0) { rh.setText("Fonte:"); } else if (rowCt == 4 && colCt == 0) { rh.setText("Fundamento:"); } else if (rowCt == 5 && colCt == 0) { rh.setText("Critrio de avaliao:"); } else if (rowCt == 6 && colCt == 0) { rh.setText("Satisfao do cliente:"); } else if (rowCt == 7 && colCt == 0) { rh.setText("Insatisfao do cliente:"); } else if (rowCt == 8 && colCt == 0) { rh.setText("Histrico:"); } if (rowCt == 0 && colCt == 1) {// Nome do requisito rh.setText(funcReq.getName()); rh.setBold(true); } else if (rowCt == 1 && colCt == 1) { // UseCases String testUC = ""; int cntUC = 0; for (UseCase uc : funcReq.getUseCaseCollection()) { if (cntUC == 0) { testUC = uc.getName(); } else { testUC = testUC + ", " + uc.getName(); } cntUC++; } rh.setText(testUC); } else if (rowCt == 2 && colCt == 1) {// Descrio rh.setText(funcReq.getDescription()); } else if (rowCt == 3 && colCt == 1) {// Fonte rh.setText(funcReq.getSource()); } else if (rowCt == 4 && colCt == 1) {// Fundamento rh.setText(funcReq.getReason()); } else if (rowCt == 5 && colCt == 1) {// Criterio de Avalicao rh.setText(funcReq.getAvaliationCriteria()); } else if (rowCt == 6 && colCt == 1) {// Prioridade rh.setText(funcReq.getClientPriority().toString()); } else if (rowCt == 7 && colCt == 1) {// Insatisfao rh.setText(funcReq.getClientInsatisfaction().toString()); } else if (rowCt == 8 && colCt == 1) {// Historico rh.setText("Histrico"); } cell.getCTTc().addNewTcPr().addNewTcW().setW(BigInteger.valueOf(cols[colCt])); colCt++; } colCt = 0; rowCt++; } doc.createParagraph().createRun().addBreak(); }
From source file:org.obeonetwork.m2doc.generator.M2DocEvaluator.java
License:Open Source License
/** * Fill a newly created word table with the data from an MTable. * //from w w w .ja va2 s. c om * @param table * The newly created word table * @param mtable * The MTable that describes the data and styles to insert */ private void fillTable(XWPFTable table, MTable mtable) { List<MRow> rows = mtable.getRows(); // Iterate over the rows for (int rowIdx = 0; rowIdx < rows.size(); rowIdx++) { MRow mRow = rows.get(rowIdx); // Get or create XWPF row XWPFTableRow xwpfRow; if (table.getNumberOfRows() > rowIdx) { xwpfRow = table.getRow(rowIdx); } else { xwpfRow = table.createRow(); } // Iterate over the columns for (int colIdx = 0; colIdx < mtable.getColumnsCount(); colIdx++) { // Get or create XWPF cell XWPFTableCell xwpfCell; if (xwpfRow.getTableCells().size() > colIdx) { xwpfCell = xwpfRow.getCell(colIdx); } else { xwpfCell = xwpfRow.createCell(); } // Populate cell XWPFParagraph xwpfCellParagraph = xwpfCell.getParagraphs().get(0); xwpfCellParagraph.setSpacingBefore(0); xwpfCellParagraph.setSpacingAfter(0); MCell mCell = null; if (colIdx < mRow.getCells().size()) { mCell = mRow.getCells().get(colIdx); } setCellContent(xwpfCell, mCell); } } }
From source file:org.obeonetwork.m2doc.generator.TableClientProcessor.java
License:Open Source License
/** * Initialize properrly a new table cell to make it easy to insert the data in this cell. Deals with the style to apply to this cell * depending on the row and column it belongs to. * // ww w . ja va 2 s . c o m * @param cell * Newly created cell to initialize * @param row * The row the cell belongs to, the style of which will be used for the cell if defined. * @param column * The column the cell belongs to, the style of which will be used for the cell if defined and the row's style is * <code>null</code>. * @return The paragraph of the cell after initialization. */ private XWPFParagraph initializeEmptyTableCell(XWPFTableCell cell, MRow row, MColumn column) { XWPFParagraph cellParagraph = cell.getParagraphs().get(0); cellParagraph.setSpacingBefore(0); cellParagraph.setSpacingAfter(0); MStyle style = row == null ? null : row.getStyle(); if (style == null) { style = column == null ? null : column.getStyle(); } if (style != null) { cell.setColor(hexColor(style.getBackgroundColor())); } return cellParagraph; }
From source file:ru.ksu.niimm.cll.mocassin.rdf.ontology.util.OntologyReportGenerator.java
License:Open Source License
private static void addURI(XWPFDocument wordDocument, OntClass ontClass) { XWPFParagraph paragraph = wordDocument.createParagraph(); paragraph.setSpacingBefore(10); paragraph.setStyle("Heading 5"); XWPFRun run = paragraph.createRun(); run.setText(formatURI(ontClass));//from w w w . java 2 s .c o m }