@@ -216,7 +216,7 @@ private void buildFirstPageHeaders(BaseTable table, JSONObject settings, Map<Str
216216 for (int i = 0 ; i < columnsOrdered .length (); i ++) {
217217
218218 JSONObject column = columnsOrdered .getJSONObject (i );
219- String columnName = column .getString ("header " );
219+ String columnName = column .getString ("alias " );
220220
221221 Cell <PDPage > cell = headerRow .createCell (columnPercentWidths [i ], columnName ,
222222 HorizontalAlignment .get ("center" ), VerticalAlignment .get ("top" ));
@@ -429,8 +429,12 @@ private void applyWholeRowStyle(int c, List<Boolean> styleCanBeOverriddenByWhole
429429 }
430430
431431 private void applyStyleToCell (Style style , Cell <PDPage > cell ) {
432- cell .setFillColor (getJavaColorFromRGBA (style .getBackgroundColor ()));
433- cell .setTextColor (getJavaColorFromRGBA (style .getColor ()));
432+ if (!style .getBackgroundColor ().isEmpty ()) {
433+ cell .setFillColor (getJavaColorFromRGBA (style .getBackgroundColor ()));
434+ }
435+ if (!style .getColor ().isEmpty ()) {
436+ cell .setTextColor (getJavaColorFromRGBA (style .getColor ()));
437+ }
434438 }
435439
436440
@@ -447,30 +451,30 @@ private Style getCellStyleByStyleKey(String styleKey, Map<String, Style> columns
447451
448452
449453 private Color getJavaColorFromRGBA (String colorStr ) {
450- String [] values = colorStr .replace (colorStr .contains ("rgba(" ) ? "rgba(" : "rgb(" , "" ).replace (")" , "" ).split ("," );
451- int red = Integer .parseInt (values [0 ].trim ());
452- int green = Integer .parseInt (values [1 ].trim ());
453- int blue = Integer .parseInt (values [2 ].trim ());
454-
455- // Handle alpha transparency
456- if (values .length > 3 ) {
457- float alpha = Float .parseFloat (values [3 ].trim ());
458-
459- // For partial transparency, blend with white background
460- // This simulates how transparent colors appear on a white Excel background
461- if (alpha <= 1.0f ) {
462- red = (int ) (red * alpha + 255 * (1 - alpha ));
463- green = (int ) (green * alpha + 255 * (1 - alpha ));
464- blue = (int ) (blue * alpha + 255 * (1 - alpha ));
454+ String [] values = colorStr .replace (colorStr .contains ("rgba(" ) ? "rgba(" : "rgb(" , "" ).replace (")" , "" ).split ("," );
455+ int red = Integer .parseInt (values [0 ].trim ());
456+ int green = Integer .parseInt (values [1 ].trim ());
457+ int blue = Integer .parseInt (values [2 ].trim ());
458+
459+ // Handle alpha transparency
460+ if (values .length > 3 ) {
461+ float alpha = Float .parseFloat (values [3 ].trim ());
462+
463+ // For partial transparency, blend with white background
464+ // This simulates how transparent colors appear on a white Excel background
465+ if (alpha <= 1.0f ) {
466+ red = (int ) (red * alpha + 255 * (1 - alpha ));
467+ green = (int ) (green * alpha + 255 * (1 - alpha ));
468+ blue = (int ) (blue * alpha + 255 * (1 - alpha ));
469+ }
465470 }
466- }
467471
468- // Ensure values are within valid range
469- red = Math .max (0 , Math .min (255 , red ));
470- green = Math .max (0 , Math .min (255 , green ));
471- blue = Math .max (0 , Math .min (255 , blue ));
472+ // Ensure values are within valid range
473+ red = Math .max (0 , Math .min (255 , red ));
474+ green = Math .max (0 , Math .min (255 , green ));
475+ blue = Math .max (0 , Math .min (255 , blue ));
472476
473- return new Color (red , green , blue );
477+ return new Color (red , green , blue );
474478 }
475479
476480
@@ -496,7 +500,7 @@ private PDPage createPage(JSONObject widget) {
496500 try {
497501 JSONObject settings = widget .getJSONObject ("settings" );
498502 JSONObject exportPdf = getJsonObjectUtils ().getConfigurationFromSettings (settings ).optJSONObject ("exports" ).optJSONObject ("pdf" );
499- int columnsLength = widget .getJSONObject ("columns" ).length ();
503+ int columnsLength = widget .getJSONArray ("columns" ).length ();
500504 if (exportPdf == null || exportPdf .length () == 0 ) {
501505 return new PDPage (calculateTableDimensions (columnsLength ));
502506 } else if (exportPdf .optBoolean ("a4portrait" )) {
0 commit comments