@@ -60,9 +60,9 @@ public class DashboardExcelExporter extends DashboardExporter {
6060 private static final String CONFIG_NAME_FOR_EXPORT_SCRIPT_PATH = "internal.nodejs.chromium.export.path" ;
6161 private static final String CONFIG_NAME_FOR_DRIVERS_SHEET_EXPORT = "DASHBOARD.EXPORT.SHOW_DRIVERS_SHEET" ;
6262 private static final String CONFIG_NAME_FOR_SELECTIONS_SHEET_EXPORT = "DASHBOARD.EXPORT.SHOW_SELECTIONS_SHEET" ;
63- private static final String CONFIG_NAME_FOR_DISABLE_STYLE = "DASHBOARD.XLSX.EXPORT.DISABLE_STYLE" ;
6463 private static final String SCRIPT_NAME = "cockpit-export-xls.js" ;
6564 private static final String DOCUMENT_NAME = "" ;
65+ private static final String XLSX_STYLE_ENABLED = "xlsxStyleEnabled" ;
6666 private String role ;
6767 private String requestURL = "" ;
6868 private String organization = "" ;
@@ -91,6 +91,24 @@ public DashboardExcelExporter(JSONObject body, String role, String requestUrl, S
9191 this .organization = organization ;
9292 }
9393
94+ static boolean isXlsxStyleEnabled (JSONObject body , boolean isDashboardSingleWidgetExport ) {
95+ if (body == null ) {
96+ return true ;
97+ }
98+ if (isDashboardSingleWidgetExport ) {
99+ return body .optBoolean (XLSX_STYLE_ENABLED , true );
100+ }
101+ JSONObject configuration = body .optJSONObject ("configuration" );
102+ if (configuration == null ) {
103+ return true ;
104+ }
105+ JSONObject menuWidgets = configuration .optJSONObject ("menuWidgets" );
106+ if (menuWidgets == null ) {
107+ return true ;
108+ }
109+ return menuWidgets .optBoolean (XLSX_STYLE_ENABLED , true );
110+ }
111+
94112 public byte [] getScheduledBinaryData (String documentLabel ) throws IOException , InterruptedException {
95113 try {
96114 Path outputDir ;
@@ -214,12 +232,7 @@ public byte[] getDashboardBinaryData(JSONObject body, boolean isDashboardSingleW
214232 JSONArray driversFromBody = getDrivers (body );
215233 JSONObject drivers = transformDriversForDatastore (driversFromBody );
216234 JSONArray parameters = getParametersFromBody (body );
217-
218- IConfigDAO configsDao = DAOFactory .getSbiConfigDAO ();
219- Optional <Config > disableStyleCfg = configsDao .loadConfigParametersByLabelIfExist (CONFIG_NAME_FOR_DISABLE_STYLE );
220- if (disableStyleCfg .isPresent () && disableStyleCfg .get ().isActive ()) {
221- this .disableBasicStyle = Boolean .parseBoolean (disableStyleCfg .get ().getValueCheck ());
222- }
235+ this .disableBasicStyle = !isXlsxStyleEnabled (body , isDashboardSingleWidgetExport );
223236
224237 if (isDashboardSingleWidgetExport ) {
225238 if (body .has ("datasetDrivers" ) && body .getJSONArray ("datasetDrivers" ) != null && body .getJSONArray ("datasetDrivers" ).length () > 0 ) {
@@ -233,6 +246,7 @@ public byte[] getDashboardBinaryData(JSONObject body, boolean isDashboardSingleW
233246 }
234247
235248
249+ IConfigDAO configsDao = DAOFactory .getSbiConfigDAO ();
236250 Optional <Config > selectionsCfg = configsDao .loadConfigParametersByLabelIfExist (CONFIG_NAME_FOR_SELECTIONS_SHEET_EXPORT );
237251
238252 if (selectionsCfg .isPresent () && selectionsCfg .get ().isActive () && Boolean .parseBoolean (selectionsCfg .get ().getValueCheck ()) && !selections .isEmpty ()) {
@@ -280,6 +294,7 @@ public byte[] getPivotBinaryData(JSONObject body) {
280294 throw new SpagoBIRuntimeException ("Unable to get template for dashboard" );
281295 }
282296 try {
297+ this .disableBasicStyle = !isXlsxStyleEnabled (body , true );
283298 Map <String , Map <String , Object >> selections = getSelections (body );
284299
285300 JSONArray driversFromBody = getDrivers (body );
0 commit comments