@@ -52,7 +52,6 @@ public class DashboardExcelExporter extends Common {
5252 private static final String [] WIDGETS_TO_IGNORE = {"image" , "text" , "selector" , "selection" , "html" };
5353 private static final int SHEET_NAME_MAX_LEN = 31 ;
5454 protected static final String DATE_FORMAT = "dd/MM/yyyy" ;
55- public static final String TIMESTAMP_FORMAT = "dd/MM/yyyy HH:mm:ss.SSS" ;
5655
5756 private final StyleProvider styleProvider ;
5857 private final JSONObjectUtils jsonObjectUtils ;
@@ -141,9 +140,6 @@ public byte[] getScheduledBinaryData(String documentLabel) throws IOException, I
141140 LOGGER .info ("CONFIG label=\" KNOWAGE.DASHBOARD.EXTERNAL_PROCESS_NAME\" : " + cockpitExportExternalProcessName );
142141
143142 String stringifiedRequestUrl = url .toString ();
144- // replace localhost:8080 with 127.0.0.1:3000
145- // stringifiedRequestUrl = stringifiedRequestUrl.replace("localhost:8080", "127.0.0.1:3000");
146-
147143 ProcessBuilder processBuilder = new ProcessBuilder (cockpitExportExternalProcessName , exportScriptFullPath .toString (),
148144 encodedUserId , outputDir .toString (), stringifiedRequestUrl );
149145
@@ -977,7 +973,7 @@ private JSONArray getDashboardWidgetsJson(String templateString) {
977973 }
978974 }
979975
980- private void doTypeLogic (Workbook wb , int precision , String type , Cell cell , String stringifiedValue ) {
976+ private void setFormattedCellValue (Workbook wb , int precision , String type , Cell cell , String stringifiedValue ) {
981977 CreationHelper creationHelper = wb .getCreationHelper ();
982978
983979 DateFormat dateFormat = new SimpleDateFormat (DATE_FORMAT , getLocale ());
@@ -1005,6 +1001,15 @@ private void doTypeLogic(Workbook wb, int precision, String type, Cell cell, Str
10051001 LOGGER .debug ("Date will be exported as string due to error: " , e );
10061002 cell .setCellValue (stringifiedValue );
10071003 }
1004+ case "string" :
1005+ if (!stringifiedValue .trim ().isEmpty ()) {
1006+ try {
1007+ cell .getCellStyle ().setDataFormat (getFormat (precision , creationHelper ));
1008+ cell .setCellValue (Integer .parseInt (stringifiedValue ));
1009+ } catch (Exception e ) {
1010+ cell .setCellValue (stringifiedValue );
1011+ }
1012+ }
10081013 break ;
10091014 default :
10101015 cell .setCellValue (stringifiedValue );
@@ -1058,7 +1063,7 @@ public void fillTableSheetWithData(JSONObject dataStore, Workbook wb, Sheet shee
10581063 JSONArray columnsOrdered ;
10591064 List <String > hiddenColumns ;
10601065 if (widgetData .has ("columns" ) && widgetData .getJSONArray ("columns" ).length () > 0 ) {
1061- hiddenColumns = getDashboardHiddenColumnsList (settings );
1066+ hiddenColumns = getDashboardHiddenColumnsList (settings , "hide" );
10621067 columnsOrdered = getDashboardTableOrderedColumns (columnSelectedOfDataset , hiddenColumns , columns );
10631068 } else {
10641069 columnsOrdered = columns ;
@@ -1265,7 +1270,7 @@ private CellStyle buildCols(Workbook wb, Sheet sheet, JSONObject settings, JSONA
12651270 String stringifiedValue = value != null ? value .toString () : "" ;
12661271
12671272 String styleKey ;
1268- if (r >= rows .length () - numberOfSummaryRows ) {
1273+ if (r >= rows .length () - numberOfSummaryRows && ! styleProvider . styleIsEmpty ( styleProvider . getStyleCustomObjFromProps ( sheet , settings . getJSONObject ( "style" ). getJSONObject ( "summary" ), "" )) ) {
12691274 CellStyle summaryCellStyle = styleProvider .buildPoiCellStyle (styleProvider .getStyleCustomObjFromProps (sheet , settings .getJSONObject ("style" ).getJSONObject ("summary" ), "" ), (XSSFFont ) wb .createFont (), wb );
12701275 cell .setCellStyle (summaryCellStyle );
12711276 } else {
@@ -1288,13 +1293,30 @@ private CellStyle buildCols(Workbook wb, Sheet sheet, JSONObject settings, JSONA
12881293 }
12891294 cell .setCellStyle (cellStyle );
12901295 }
1291- doTypeLogic ( wb , getPrecisionByColumn (settings , column ), type , cell , stringifiedValue );
1296+ int precision = getPrecisionByColumn (settings , column );
12921297
1293- if (r >= rows .length () - numberOfSummaryRows ) {
1294- cell .setCellValue (summaryRowsLabels .get (r - (rows .length () - numberOfSummaryRows )).concat (": " ).concat (stringifiedValue ));
1298+ if (r < rows .length () - numberOfSummaryRows ) {
1299+ setFormattedCellValue (wb , precision , type , cell , stringifiedValue );
1300+ } else {
1301+ if (isSummaryColumnVisible (getDashboardHiddenColumnsList (settings , "hideFromSummary" ), column )) {
1302+ String label = "" ;
1303+ if (colIndex .equals ("column_1" )) {
1304+ label = summaryRowsLabels .get (r - (rows .length () - numberOfSummaryRows )).concat (" " );
1305+ }
1306+ cell .setCellStyle (cellStyle );
1307+ setFormattedCellValue (wb , precision , type , cell , label .concat (stringifiedValue ));
1308+ }
1309+ }
12951310 }
1311+ return cellStyle ;
1312+ }
1313+
1314+ private boolean isSummaryColumnVisible (List <String > columnsToHide , JSONObject column ) {
1315+ try {
1316+ return !columnsToHide .contains (column .getString ("id" ));
1317+ } catch (JSONException e ) {
1318+ throw new SpagoBIRuntimeException (e );
12961319 }
1297- return cellStyle ;
12981320 }
12991321
13001322 private String getCellType (JSONObject column , String colName ) {
@@ -1440,7 +1462,7 @@ private DataConsolidateFunction getAggregationFunction(String aggregation) {
14401462 };
14411463 }
14421464
1443- protected List <String > getDashboardHiddenColumnsList (JSONObject settings ) {
1465+ protected List <String > getDashboardHiddenColumnsList (JSONObject settings , String conditionToEvaluate ) {
14441466 try {
14451467 List <String > hiddenColumns = new ArrayList <>();
14461468 if (areVisibilityConditionsEnabled (settings )) {
@@ -1450,7 +1472,7 @@ protected List<String> getDashboardHiddenColumnsList(JSONObject settings) {
14501472
14511473 for (int i = 0 ; i < conditions .length (); i ++) {
14521474 JSONObject condition = conditions .getJSONObject (i );
1453- if (columnMustBeHidden (condition )) {
1475+ if (columnMustBeHidden (condition , conditionToEvaluate )) {
14541476 JSONArray target ;
14551477 try {
14561478 target = condition .getJSONArray ("target" );
@@ -1472,22 +1494,22 @@ protected List<String> getDashboardHiddenColumnsList(JSONObject settings) {
14721494 }
14731495 }
14741496
1475- private boolean columnMustBeHidden (JSONObject condition ) {
1497+ private boolean columnMustBeHidden (JSONObject condition , String conditionToEvaluate ) {
14761498 try {
14771499 JSONObject conditionDefinition = condition .getJSONObject ("condition" );
14781500
1501+
14791502 return (conditionDefinition .getString ("type" ).equals ("always" ) &&
1480- condition .getBoolean ("hide" ))
1503+ condition .getBoolean (conditionToEvaluate ))
14811504 ||
14821505 (conditionDefinition .getString ("type" ).equals ("variable" ) &&
1483- condition .getBoolean ("hide" ) && conditionIsApplicable (conditionDefinition .getString ("variableValue" ), conditionDefinition .getString ("operator" ), conditionDefinition .getString ("value" )));
1506+ condition .getBoolean (conditionToEvaluate ) && conditionIsApplicable (conditionDefinition .getString ("variableValue" ), conditionDefinition .getString ("operator" ), conditionDefinition .getString ("value" )));
14841507
14851508 } catch (JSONException jsonException ) {
14861509 LOGGER .error ("Error while evaluating if column must be hidden according to variable." , jsonException );
14871510 return false ;
14881511 }
14891512 }
1490-
14911513 private boolean areVisibilityConditionsEnabled (JSONObject settings ) throws JSONException {
14921514 JSONObject visualization = jsonObjectUtils .getVisualizationFromSettings (settings );
14931515 return settings .has ("visualization" ) &&
0 commit comments