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()) {
|
if (!results.isEmpty()) {
|
||||||
List<String> headers = new ArrayList<>(results.get(0).keySet());
|
List<String> headers = new ArrayList<>(results.get(0).keySet());
|
||||||
writer.write(String.join(",", headers));
|
writer.write(String.join(",", headers));
|
||||||
writer.newLine();
|
writer.write("\r\n");
|
||||||
|
|
||||||
for (Map<String, Object> row : results) {
|
for (Map<String, Object> row : results) {
|
||||||
List<String> rowValues = headers.stream()
|
List<String> rowValues = headers.stream()
|
||||||
.map(header -> formatCsvField(row.get(header)))
|
.map(header -> formatCsvField(row.get(header)))
|
||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
writer.write(String.join(",", rowValues));
|
writer.write(String.join(";", rowValues));
|
||||||
writer.newLine();
|
writer.write("\r\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -300,11 +300,16 @@ public class DownloadService {
|
||||||
|
|
||||||
private String formatCsvField(Object value) {
|
private String formatCsvField(Object value) {
|
||||||
if (value == null) {
|
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 + "\"";
|
||||||
}
|
}
|
||||||
|
return strValue;
|
||||||
|
}
|
||||||
|
|
||||||
private String formatCsvRow(String[] row) {
|
private String formatCsvRow(String[] row) {
|
||||||
StringBuilder formattedRow = new StringBuilder();
|
StringBuilder formattedRow = new StringBuilder();
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue