Skip to content

Commit

Permalink
Table Export : Modify right margin (eclipse-set#1071)
Browse files Browse the repository at this point in the history
* Modify distance recht border

* add comment, change variable name

* Fix table width by multipage
  • Loading branch information
TruongQuangSB committed Nov 22, 2024
1 parent fe6a7db commit df69b30
Show file tree
Hide file tree
Showing 25 changed files with 24 additions and 11 deletions.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@
*/
public abstract class AbstractTransformTableHeader {
protected static final String XSL_TEMPLATE_PATH = "data/export/pdf/table_template.xsl"; //$NON-NLS-1$
protected static final float OFFSET = 0.01f;

protected Document doc;
protected XSSFSheet sheet;
Expand Down Expand Up @@ -183,6 +184,7 @@ protected Element transformTable() {
return tableTemplate;
}

@SuppressWarnings("nls")
private Set<Element> transformColumns() {
final LinkedHashSet<Element> cols = new LinkedHashSet<>();
float sumWidth = 0f;
Expand All @@ -193,6 +195,15 @@ private Set<Element> transformColumns() {
columNumber = pair.getKey().intValue();
sumWidth = pair.getValue().floatValue();
}

// Fill remaining page width
if (sumWidth < maxPaperWidth - OFFSET) {
final float remainingWidth = maxPaperWidth - sumWidth - OFFSET;
final float lastColumnWith = Float.parseFloat(cols.getLast()
.getAttribute(COLUMN_WIDTH).replace("cm", ""));
cols.getLast().setAttribute(COLUMN_WIDTH,
Double.toString(lastColumnWith + remainingWidth) + "cm");
}
return cols;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,35 +83,37 @@ class MultiPageTableHeader extends AbstractTransformTableHeader {

// Add last column in page
cols.add(createTableColumn(columNumber, columnWidth))

// Add repeating column to new page
val newColNumber = cols.transformBreakColumns(columNumber)
return Pair.of(newColNumber, 0f)
val repeatColumns = cols.transformBreakColumns(columNumber)
return Pair.of(repeatColumns.key, repeatColumns.value)
} else {
cols.add(createTableColumn(columNumber, columnWidth))
return Pair.of(columNumber, sumWidth + columnWidth)
}

}

private def int transformBreakColumns(LinkedHashSet<Element> columns,
private def Pair<Integer, Float> transformBreakColumns(LinkedHashSet<Element> columns,
int columnNumber) {
val repeatingColumns = getRepeatingColumns(sheet)
if (repeatingColumns.empty) {
// When repeating columns is empty,
// then add only numerical order column
val columnWidth = sheet.getColumnWidthInCm(0).floatValue
columns.add(
createTableColumn(columnNumber,
sheet.getColumnWidthInCm(0).floatValue))
return columnNumber + 1
columnWidth))
return columnNumber + 1 -> columnWidth
}
repeatingColumns.forEach [ col, index |
var repeatColumnsWidth = 0f;
for (var index = 0; index < repeatingColumns.size; index++) {
val colIndex = columnNumber + index + 1
val columnWidth = sheet.getColumnWidthInCm(repeatingColumns.toList.get(index)).floatValue
repeatColumnsWidth += columnWidth
columns.add(
createTableColumn(colIndex,
sheet.getColumnWidthInCm(col).floatValue))
]
return columnNumber + repeatingColumns.size
createTableColumn(colIndex,columnWidth))
}
return columnNumber + repeatingColumns.size -> repeatColumnsWidth
}

override protected getCellSpanColumn(Optional<Cell> excelCell) {
Expand Down

0 comments on commit df69b30

Please sign in to comment.