Skip to content

Commit a3dd6ff

Browse files
committed
[KNOWAGE-9263] handle zero precision formatting in Excel summary row export
1 parent d501e73 commit a3dd6ff

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

  • knowage-excel-export/src/main/java/it/eng/knowage/engine/api/excel/export/oldcockpit

knowage-excel-export/src/main/java/it/eng/knowage/engine/api/excel/export/oldcockpit/ExcelExporter.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1037,10 +1037,14 @@ private boolean isSummaryRow(int r, JSONArray rows, int numberOfSummaryRows) {
10371037

10381038
private static void setSummaryRowValue(JSONObject[] columnStyles, int c, Object value, Cell cell, String summaryRowLabel, JSONObject column, boolean isOnlyPinned) {
10391039
try {
1040-
int precision = (columnStyles[c] != null && columnStyles[c].has("precision") && columnStyles[c].optInt("precision") != 0) ? columnStyles[c].getInt("precision") : 2;
1040+
int precision = (columnStyles[c] != null && columnStyles[c].has("precision")) ? columnStyles[c].getInt("precision") : 2;
10411041
String formattedValue;
10421042
try {
1043-
formattedValue = new DecimalFormat("#,##0." + StringUtils.repeat("0", precision)).format(value);
1043+
if (precision == 0) {
1044+
formattedValue = new DecimalFormat("#,##0").format(value);
1045+
} else {
1046+
formattedValue = new DecimalFormat("#,##0." + StringUtils.repeat("0", precision)).format(value);
1047+
}
10441048
} catch (Exception e) {
10451049
formattedValue = value.toString();
10461050
}

0 commit comments

Comments
 (0)