List of usage examples for org.apache.poi.xwpf.usermodel XWPFTableCell setText
public void setText(String text)
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 *///w w w. j a v a 2 s .c om 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); } }
From source file:org.goobi.production.flow.helper.SearchResultHelper.java
License:Open Source License
public XWPFDocument getResultAsWord(List<SearchColumn> columnList, String filter, String order, boolean showClosedProcesses, boolean showArchivedProjects) { @SuppressWarnings("rawtypes") List list = search(columnList, filter, order, showClosedProcesses, showArchivedProjects); XWPFDocument doc = new XWPFDocument(); // create header row int colNum = columnList.size(); int rowNum = list.size() + 1; XWPFTable table = doc.createTable(rowNum, colNum); CTTblWidth width = table.getCTTbl().addNewTblPr().addNewTblW(); width.setType(STTblWidth.DXA);//from w w w. j av a2s.co m width.setW(BigInteger.valueOf(10000)); int currentRow = 0; int currentCol = 0; XWPFTableRow headerRow = table.getRow(currentRow++); for (SearchColumn sc : columnList) { XWPFTableCell cell = headerRow.getCell(currentCol++); cell.setText(Helper.getTranslation(sc.getValue())); } for (Object obj : list) { currentCol = 0; Object[] objArr = (Object[]) obj; XWPFTableRow row = table.getRow(currentRow++); for (Object entry : objArr) { XWPFTableCell cell = row.getCell(currentCol++); cell.setText((String) entry); } } return doc; }
From source file:org.ohdsi.rabbitInAHat.ETLDocumentGenerator.java
License:Apache License
private static void setTextAndHeaderShading(XWPFTableCell cell, String text) { cell.setText(text); cell.setColor("AAAAFF"); // CTShd ctshd = cell.getCTTc().addNewTcPr().addNewShd(); // ctshd.setColor("FFFFFF"); // ctshd.setVal(STShd.CLEAR); // ctshd.setFill("6666BB"); }
From source file:service.GenerationLettres.CreerPiecesManquantes.java
/** * * @param filename - Nom du fichier modle de demande des pices manquantes. * @param idDossier - Identifiant du dossier pour lequel l est cr * @throws InvalidFormatException/* ww w . j a va 2s . c om*/ * @throws IOException */ public void replacePiecesManquantes(String filename, Formation formation, String sexe, String nom, String prenom, String adresse, Adresse adresseEntite, List<Justificatif> justificatifsOk) throws InvalidFormatException, IOException { List<Justificatif> lesJustificatifs = formation.getLesJustificatifs(); Date dateActuelle = new Date(); DateFormat dateForm = new SimpleDateFormat("dd MMMM yyyy", Locale.FRANCE); String date = dateForm.format(dateActuelle); String codePostal = adresseEntite.getCodePostal(); String ville = adresseEntite.getVille(); String civilite = ""; if (sexe.equals("Masculin")) civilite = "Monsieur"; if (sexe.equals("Feminin")) civilite = "Madame"; String intitule = formation.getIntitule(); if (justificatifsOk != null) { for (Justificatif just : justificatifsOk) { lesJustificatifs.remove(just); } } String newFileName = nom + prenom + " Lettre piecesManquantes.docx"; File file = new File(PATH_MODELS + "/" + filename); FileInputStream fis = new FileInputStream(file.getAbsolutePath()); XWPFDocument doc = new XWPFDocument(fis); doc.write(new FileOutputStream(PATH_TARGET + "/" + newFileName)); doc.close(); doc = new XWPFDocument(OPCPackage.open(PATH_TARGET + "/" + newFileName)); for (XWPFParagraph p : doc.getParagraphs()) { int numberOfRuns = p.getRuns().size(); StringBuilder sb = new StringBuilder(); for (XWPFRun r : p.getRuns()) { int pos = r.getTextPosition(); if (r.getText(pos) != null) { sb.append(r.getText(pos)); } } if (sb.length() > 0 && sb.toString().contains("$formation")) { for (int i = numberOfRuns - 1; i > 0; i--) { p.removeRun(i); } String text = sb.toString().replace("$formation", intitule); XWPFRun run = p.getRuns().get(0); run.setText(text, 0); System.out.println("Changement de la formation effectue"); } } for (XWPFParagraph p : doc.getParagraphs()) { int numberOfRuns = p.getRuns().size(); StringBuilder sb = new StringBuilder(); for (XWPFRun r : p.getRuns()) { int pos = r.getTextPosition(); if (r.getText(pos) != null) { sb.append(r.getText(pos)); } } if (sb.length() > 0 && sb.toString().contains("$date")) { for (int i = numberOfRuns - 1; i > 0; i--) { p.removeRun(i); } String text = sb.toString().replace("$date", date); XWPFRun run = p.getRuns().get(0); run.setText(text, 0); System.out.println("Changement de la date effectue"); } } for (XWPFParagraph p : doc.getParagraphs()) { int numberOfRuns = p.getRuns().size(); StringBuilder sb = new StringBuilder(); for (XWPFRun r : p.getRuns()) { int pos = r.getTextPosition(); if (r.getText(pos) != null) { sb.append(r.getText(pos)); } } if (sb.length() > 0 && sb.toString().contains("$civilite")) { for (int i = numberOfRuns - 1; i > 0; i--) { p.removeRun(i); } String text = sb.toString().replace("$civilite", civilite); XWPFRun run = p.getRuns().get(0); run.setText(text, 0); System.out.println("Changement de la civilite effectue"); } } for (XWPFParagraph p : doc.getParagraphs()) { int numberOfRuns = p.getRuns().size(); StringBuilder sb = new StringBuilder(); for (XWPFRun r : p.getRuns()) { int pos = r.getTextPosition(); if (r.getText(pos) != null) { sb.append(r.getText(pos)); } } if (sb.length() > 0 && sb.toString().contains("$prenom")) { for (int i = numberOfRuns - 1; i > 0; i--) { p.removeRun(i); } String text = sb.toString().replace("$prenom", prenom); XWPFRun run = p.getRuns().get(0); run.setText(text, 0); System.out.println("Changement du prenom effectue"); } } for (XWPFParagraph p : doc.getParagraphs()) { int numberOfRuns = p.getRuns().size(); StringBuilder sb = new StringBuilder(); for (XWPFRun r : p.getRuns()) { int pos = r.getTextPosition(); if (r.getText(pos) != null) { sb.append(r.getText(pos)); } } if (sb.length() > 0 && sb.toString().contains("$nom")) { for (int i = numberOfRuns - 1; i > 0; i--) { p.removeRun(i); } String text = sb.toString().replace("$nom", nom); XWPFRun run = p.getRuns().get(0); run.setText(text, 0); System.out.println("Changement du nom effectue"); } } for (XWPFParagraph p : doc.getParagraphs()) { int numberOfRuns = p.getRuns().size(); StringBuilder sb = new StringBuilder(); for (XWPFRun r : p.getRuns()) { int pos = r.getTextPosition(); if (r.getText(pos) != null) { sb.append(r.getText(pos)); } } if (sb.length() > 0 && sb.toString().contains("$adresse")) { for (int i = numberOfRuns - 1; i > 0; i--) { p.removeRun(i); } String text = sb.toString().replace("$adresse", adresse); XWPFRun run = p.getRuns().get(0); run.setText(text, 0); System.out.println("Changement de l'adresse effectue"); } } for (XWPFParagraph p : doc.getParagraphs()) { int numberOfRuns = p.getRuns().size(); StringBuilder sb = new StringBuilder(); for (XWPFRun r : p.getRuns()) { int pos = r.getTextPosition(); if (r.getText(pos) != null) { sb.append(r.getText(pos)); } } if (sb.length() > 0 && sb.toString().contains("$codePostal")) { for (int i = numberOfRuns - 1; i > 0; i--) { p.removeRun(i); } String text = sb.toString().replace("$codePostal", codePostal); XWPFRun run = p.getRuns().get(0); run.setText(text, 0); System.out.println("Changement du code postal effectue"); } } for (XWPFParagraph p : doc.getParagraphs()) { int numberOfRuns = p.getRuns().size(); StringBuilder sb = new StringBuilder(); for (XWPFRun r : p.getRuns()) { int pos = r.getTextPosition(); if (r.getText(pos) != null) { sb.append(r.getText(pos)); } } if (sb.length() > 0 && sb.toString().contains("$ville")) { for (int i = numberOfRuns - 1; i > 0; i--) { p.removeRun(i); } String text = sb.toString().replace("$ville", ville); XWPFRun run = p.getRuns().get(0); run.setText(text, 0); System.out.println("Changement de la ville effectue"); } } XWPFTable table = doc.createTable(lesJustificatifs.size(), 2); table.setCellMargins(200, 250, 0, 250); int i = 0; for (XWPFTableRow r : table.getRows()) { XWPFTableCell cell = r.getCell(0); cell.setText(lesJustificatifs.get(i).getTitre()); cell = r.getCell(1); cell.setText(lesJustificatifs.get(i).getDescription()); i++; } doc.write(new FileOutputStream(PATH_TARGET + "/temp.docx")); new File(PATH_TARGET + "/temp.docx").delete(); doc.close(); //copyTempToFile(filename); System.out.println("replaceLettrePiecesManquantes DONE"); }