JasperReports exported to Excel ignoring background color?
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!
Asked by: Adelaide343 | Posted: 28-01-2022
Answer 1
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.
Answered by: Julia542 | Posted: 01-03-2022Answer 2
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 )
Answered by: Rafael445 | Posted: 01-03-2022on it without using a rectangle and a print when expression on it!
Similar questions
java - JasperReports export to Excel uses only last set background color
Im pretty pretty new to Dynamic-Jasper, but due to work i had to add a new feature to our already implemented solution.
My Problem
The Goal is to add a Column to a report that consists only out of a background-color based on some Information. I managed to do that, but while testing I stumbled upon a Problem. While all my Columns in the html and pdf view had the right color, the Excel one on...
java - Is JasperReports can be a good replacement for a CGI based web report framework
We have a CGI based web report framework written in C/C++. The CGI client connects with proprietary code which in turn connects to database.
We are looking for a better Java based replacement for CGI due to performance, maintenance and probably security factors.
Can JasperReports connect with the proprietary code? Or will servlet be enough to replace CGI client?
java - lazily compile JasperReports .jrxml to .jasper
I use Jasper reports with the JasperReportsMultiFormatView class provided by the Spring framework. This class takes care of compiling the source .jrxml files to their compiled .jasper format when the Spring application context is created.
java - Is JasperReports the appropriate solution to display reports in a web application?
We want to generate Reports either embedded as html pages in a web app or downloadable as a pdf. Hence I came across JasperReports because it thought it would fullfill these requirements.
Currently we assume our report will have about 50-100 pages, consisting of nearly only histograms and some tables. The data is retrieved by some expensive queries from our DB.
After evaluating it the who...
java - JasperReports PDF. & character causing trouble
I am trying to create a pdf document with JasperReports. Everything works fine, except than when an & character appears, some tags are not interpreted, and appear in the final document.
Do i have to escape de "&" character? I've already tried writing & instead, as well as wrapping a around it. In the first case, & appeared in my pdf, and in the second one, the ampersand dissapeared from it.
java - Convert a parameter entered as an integer to a string in JasperReports
I have a JRXML file that I use to generate a report built on a massive SQL query for an Oracle database. I have entered a parameter to the report that gets filled as an Integer. However, I would also like to reference this parameter as a String at a different point in the query.
Is there a way I can convert the parameter from an Integer to a String within the organization of JasperReports or do I have to create a ...
java - JasperReports rendering issue
I have a very weird JasperReports rendering problem.
I am using an old version of the free Java Reporting Tool JasperReports: 1.3.4. It's being heavily used on a Swing finance application.
I use JasperViever class to show a preview of the report to print, and my weird problem is that the report shows perfectly fine on...
java - Rendering arbitrary XHTML with JasperReports
We have embedded JasperReports into our application to generate reports, but I've been rather dissatisfied with the way that the JEditorPaneHtmlMarkupProcessor handles writing arbitrary XHTML. For example, I needed to output a bulleted list at one point, which it does, but because it converts it to actual bullet characters and newlines, a bullet with fairly long text results in the text wrapping to align with the bullet, n...
java - JasperReports with resolution different than 72dpi
I've been trying to use JasperReports to print in a resolution above 72dpi, with no success.
I need to use some resolution above 72dpi because I'm going to print in those pre-formatted adhesive labels, which need a certain level of precision when setting the positions. But, as JasperReports can only use pixels, and AFAIK only supports the 72dpi configuration, I can't set the margins, spacings, etc correctly.
java - Export a report and save in a location using JasperReports
I need to export a report and save it to a location specified, I have exported the report but I want to know how to save it in a file location, it is a doc or rtf format
java - Static Members Issue - JasperReports for .Net over jni4Net
I'm trying to fill a report with empty datasource like this
JasperPrint print = JasperFillManager.fillReport(@"D:\ImagesReport.jasper", null);
Usually the program crashes without notice, but I used watch window and found that this is what I get
at net.sf.jni4net.jni.JNIEnv.CallStaticObjectMethodPtr(Class clazz, MethodId methodIdNative, Value[] args)
at net.sf.jasperre...
Still can't find your answer? Check out these amazing Java communities for help...
Java Reddit Community | Java Help Reddit Community | Dev.to Java Community | Java Discord | Java Programmers (Facebook) | Java developers (Facebook)