Fixed row shift problem

This commit is contained in:
Dominique Eifländer 2021-08-19 10:11:48 +02:00
parent 18a8cee6eb
commit 15da44cf43

View File

@ -52,7 +52,9 @@ import com.iqser.red.service.redaction.report.v1.server.storage.ReportStorageSer
import lombok.RequiredArgsConstructor;
import lombok.SneakyThrows;
import lombok.extern.slf4j.Slf4j;
@Slf4j
@Service
@RequiredArgsConstructor
public class ExcelTemplateReportGenerationService {
@ -79,7 +81,7 @@ public class ExcelTemplateReportGenerationService {
if (dossierAttribute.getDossierAttributeId().equals(attribute.getId())) {
if (attribute.getType().equals(DossierAttributeConfig.DossierAttributeType.IMAGE)) {
if(dossierAttribute.getValue() != null) {
if (dossierAttribute.getValue() != null) {
if (dossierAttribute.getValue().startsWith("data:")) {
imagePlaceholders.add(new ImagePlaceholder(attribute.getPlaceholder(), Base64.getDecoder()
.decode(dossierAttribute.getValue().split(",")[1])));
@ -145,8 +147,7 @@ public class ExcelTemplateReportGenerationService {
private void addEntryRows(Sheet sheet, List<ReportRedactionEntry> reportEntries, String filename,
boolean isLastFile) {
if (reportEntries.isEmpty()){
if (reportEntries.isEmpty()) {
return;
}
@ -177,11 +178,15 @@ public class ExcelTemplateReportGenerationService {
AtomicInteger rowIndex = new AtomicInteger(placeholderRow);
if (rowIndex.get() != -1) {
if (isLastFile) {
sheet.shiftRows(rowIndex.get(), rowIndex.get() + reportEntries.size() - 1, reportEntries.size() - 1, true, true);
if (reportEntries.size() > 1) {
sheet.shiftRows(rowIndex.get(), rowIndex.get() + reportEntries.size() - 1, reportEntries.size() - 1, true, true);
}
} else {
sheet.shiftRows(rowIndex.get(), rowIndex.get() + reportEntries.size(), reportEntries.size(), true, true);
}
reportEntries.forEach(entry -> {
sheet.createRow(rowIndex.get());
for (Map.Entry<Integer, String> entry1 : placeholderCellPos.entrySet()) {