Skip to content

Commit 7366161

Browse files
committed
[KNOWAGE-9541] keep pivot original layout
1 parent 6d58080 commit 7366161

File tree

1 file changed

+14
-6
lines changed

1 file changed

+14
-6
lines changed

knowage-export/src/main/java/it/eng/knowage/engine/api/export/dashboard/excel/exporters/DashboardPivotExporter.java

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ private void formatPivot(XSSFPivotTable pivotTable) {
118118
int counter = 0;
119119

120120
for (int i = 0; i < columns.length(); ++i) {
121-
pivotTable.addRowLabel(counter);
121+
pivotTable.addColLabel(counter);
122122
counter++;
123123
}
124124

@@ -132,11 +132,19 @@ private void formatPivot(XSSFPivotTable pivotTable) {
132132
counter++;
133133
}
134134

135-
for (int i = 0; i < data.length(); ++i) {
136-
JSONObject datum = data.getJSONObject(i);
137-
DataConsolidateFunction function = getAggregationFunction(datum.getString("aggregation").toUpperCase());
138-
pivotTable.addColumnLabel(function, counter, datum.optString("alias", datum.optString("columnName")));
139-
counter++;
135+
try {
136+
for (int i = 0; i < data.length(); ++i) {
137+
JSONObject dataObj = data.getJSONObject(i);
138+
String aggregation = dataObj.optString("aggregation", "SUM");
139+
DataConsolidateFunction func = getAggregationFunction(aggregation);
140+
if (func == null) {
141+
func = SUM;
142+
}
143+
pivotTable.addColumnLabel(func, counter);
144+
counter++;
145+
}
146+
} catch (JSONException e) {
147+
logger.error("Error while adding data columns to pivot table", e);
140148
}
141149

142150
} catch (JSONException e) {

0 commit comments

Comments
 (0)