Fix for arango report
This commit is contained in:
parent
7aa720ead6
commit
9dfdb0fd77
1 changed files with 11 additions and 6 deletions
|
|
@ -280,14 +280,14 @@ public class DownloadService {
|
|||
if (!results.isEmpty()) {
|
||||
List<String> headers = new ArrayList<>(results.get(0).keySet());
|
||||
writer.write(String.join(",", headers));
|
||||
writer.newLine();
|
||||
writer.write("\r\n");
|
||||
|
||||
for (Map<String, Object> row : results) {
|
||||
List<String> 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,11 +300,16 @@ public class DownloadService {
|
|||
|
||||
private String formatCsvField(Object value) {
|
||||
if (value == null) {
|
||||
return "\"\"";
|
||||
return "";
|
||||
}
|
||||
String strValue = value.toString().replace("\"", "\"\"");
|
||||
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) {
|
||||
StringBuilder formattedRow = new StringBuilder();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue