RED-1186: replacing placeholders in documents; TODO: adding entries to tables
This commit is contained in:
parent
0579710cd2
commit
4c2d77736d
@ -121,15 +121,36 @@ public class WordReportGenerationService {
|
||||
XWPFTable table = getTableWithPlaceholder(doc);
|
||||
|
||||
for (XWPFTableRow row : table.getRows()) {
|
||||
XWPFTableRow newRow = table.createRow();
|
||||
for (int i=0; i<row.getTableCells().size(); i++) {
|
||||
if(row.getTableCells().get(i).getText().contains(FILENAME_PLACEHOLDER)) {
|
||||
setText(row.getCell(i), filename);
|
||||
// if (row.getCell())
|
||||
|
||||
reportEntries.forEach(entry -> {
|
||||
for (int i = 0; i < row.getTableCells().size(); i++) {
|
||||
System.out.println(row.getCell(i).getText());
|
||||
String cellText = row.getCell(i).getText();
|
||||
if(containsPlaceholder(cellText)) {
|
||||
final int j = i;
|
||||
XWPFTableRow newRow = table.createRow();
|
||||
if (row.getCell(j).getText().contains(FILENAME_PLACEHOLDER)) {
|
||||
setText(newRow.getCell(j), filename);
|
||||
break;
|
||||
}
|
||||
if (row.getCell(j).getText().contains(PAGE_PLACEHOLDER)) {
|
||||
setText(newRow.getCell(j), String.valueOf(entry.getPage()));
|
||||
break;
|
||||
}
|
||||
if (row.getCell(j).getText().contains(PARAGRAPH_PLACEHOLDER)) {
|
||||
setText(newRow.getCell(j), entry.getSection());
|
||||
break;
|
||||
}
|
||||
if (row.getCell(j).getText().contains(REASON_PLACEHOLDER)) {
|
||||
setText(newRow.getCell(j), entry.getJustification());
|
||||
break;
|
||||
}
|
||||
System.out.println(row.getCell(j).getText());
|
||||
|
||||
}
|
||||
}
|
||||
if(row.getTableCells().get(i).getText().contains(PAGE_PLACEHOLDER)) {
|
||||
setText(row.getCell(i), String.valueOf(reportEntries.getPage()));
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@ -140,15 +161,17 @@ public class WordReportGenerationService {
|
||||
setText(row.getCell(1), String.valueOf(entry.getPage()));
|
||||
setText(row.getCell(2), entry.getSection());
|
||||
setText(row.getCell(3), entry.getJustification());
|
||||
System.out.println(row);
|
||||
});
|
||||
}
|
||||
|
||||
private int getCell(XWPFTableRow row,String placeholder) {
|
||||
for (int i=0; i<row.getTableCells().size(); i++) {
|
||||
if(row.getTableCells().get(i).getText().contains(placeholder)) {
|
||||
cell.
|
||||
// cell.
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user