Have you ever had alternating background colors in a Jasper report and then exported it to Excel? The Excel export seems to ignore the alternating color.
I've got a Jasper report where the rows alternating background color using the procedure referenced HERE. When I preview it using the viewer or export to PDF it works -- but not when I export to Excel. I've tried using JRXlsExporter
and JExcelApiExporter
both to no avail.
I think it might be a side-effect of how you have to make alternating row colors in Jasper, which I despise to begin with, but have found no other way.
Thanks in advance!
Also, Be sure that the conditional styles you make, have the "opaque" option checked... If not, the background color will never apper in the excel report (never!!!)....
Also, The "opaque" option must be checked in the text fields....
And if you noticed that the text fields never took the style that you gave to them, try to set the forecolor and background to null, in the properties panel of each text field (this works for me)...
Hope this help... bye.
Did you try the idea suggested in the comment of the very procedure you are referring to ?
First how to create new report style with condition:
Recent releases of JasperReports include report styles, which make this a bit easier - you no longer have to create the rectangle.
I use iReport to create my styles - there is a “styles” pane that by default is docked with the “Library” pane. If you make it visible you can create a new style in the styles library. In the screen that pops up give the style a name (say “EvenOddRowStyle” and press “Add” under “Style Conditions”. Use one of the expressions that Brian gave and press Apply. and in the “Common” section press the “…” button next to “Backcolor” and pick the background color you want. Finally, when done with your report apply that style to all the fields in the rows you want to highlight. Just drag the style from the styles pane onto the field.
Then how to define a style which will be applied when exported to Excel:
defining a new style with the condition expression:
Boolean.valueOf( $V{PAGE_COUNT}.intValue() % 2 == 0 )
on it without using a rectangle and a print when expression on it!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With