diff --git a/config-data-executor/src/main/java/org/micord/service/DownloadService.java b/config-data-executor/src/main/java/org/micord/service/DownloadService.java index 529fe6d..95106ba 100644 --- a/config-data-executor/src/main/java/org/micord/service/DownloadService.java +++ b/config-data-executor/src/main/java/org/micord/service/DownloadService.java @@ -280,14 +280,14 @@ public class DownloadService { if (!results.isEmpty()) { List headers = new ArrayList<>(results.get(0).keySet()); writer.write(String.join(",", headers)); - writer.newLine(); + writer.write("\r\n"); for (Map row : results) { List rowValues = headers.stream() .map(header -> formatCsvField(row.get(header))) .collect(Collectors.toList()); - writer.write(String.join(",", rowValues)); - writer.newLine(); + writer.write(String.join(";", rowValues)); + writer.write("\r\n"); } } } @@ -300,10 +300,15 @@ public class DownloadService { private String formatCsvField(Object value) { if (value == null) { - return "\"\""; + return ""; } - String strValue = value.toString().replace("\"", "\"\""); - return "\"" + strValue + "\""; + String strValue = value.toString(); + + if (strValue.contains(";") || strValue.contains("\"") || strValue.contains("\r") || strValue.contains("\n")) { + strValue = strValue.replace("\"", "\"\""); + return "\"" + strValue + "\""; + } + return strValue; } private String formatCsvRow(String[] row) {