I am using JasperReports to generate reports in xls format. I am trying to auto adjust the column and row with following code.
print.getPropertiesMap().setProperty("net.sf.jasperreports.print.keep.full.text", "true");
print.getPropertiesMap().setProperty("net.sf.jasperreports.export.xls.auto.fit.row","true");
print.getPropertiesMap().setProperty("net.sf.jasperreports.export.xls.auto.fit.column","true");
I can't quite figure out why this is not working.
One more property you would need
"net.sf.jasperreports.export.xls.wrap.text" to "false"
and also set isStretchWithOverflow to false
Related
When I use birt api to export excel, the excel's sheet name is default set to Sheet0. Is there a way to custom sheet name in birt API?
In the "Property Editor - Report" in the tab "General" you can enter a "Title".
This value will be taken to name the sheet when exporting to excel.
I had a report with two table and page break after the first one so each table made their own sheet. after selecting each table go to the script and in the "on create" script, code this:
this.name = "Sheet Name";
Can add Dynamic/Static Worksheet name.
Select Table, click in Script (onPrepare), use below line of code.
reportContext.getDesignHandle().setProperty("title", "Sheetname1");
Sheet name can also be passed through request parameter (workSheetName) using below line of code.
reportContext.getDesignHandle().setProperty("title", params["workSheetName"].value);
In report I have crosstab and one subreport, both in Summary Band.
Problem is repeating of Crosstab column header in XLS report.
(Want to have only one column header)
I've tried some tricks, but nothing is good enough.
1) If uncheck Crosstab Properties - Repeat Column Header result is ok but than don't have headers in HTML and PDF, it is not ok.
2) If IS_IGNORE_PAGINATION = true only for XLS, it is OK but for some reason subreport is not printing! (this is the biggest problem,don't know why?)
3) Properties like this are not applicable on CROSSTAB
result.put("net.sf.jasperreports.export.xls.exclude.origin.band.1", "pageHeader");
result.put("net.sf.jasperreports.export.xls.exclude.origin.band.2", "pageFooter");
result.put("net.sf.jasperreports.export.xls.exclude.origin.band.3", "columnHeader");
result.put("net.sf.jasperreports.export.xls.exclude.origin.keep.first.band.1", "columnHeader");
result.put("net.sf.jasperreports.export.xls.exclude.origin.keep.first.band.2", "pageHeader");
4) I have tried to put main page report page height to some big number like 999999 but still subreport is not printing if IS_IGNORE_PAGINATION = true
Is there some property for crosstab that can be set from Java, depending on output format?
I will answer to my own question.
After many attempts, due to a lack of time, I made a new report for XLS output format.
(Now I have two nearly same report, one for PDF and HTML, and other for XLS output format)
In report I have unchecked Crosstab Properties - Repeat Column Header.
The downside of this is maintenance, but for now this is the only solution.
I have a string like "2,345".I want to put it into a excel cell.I successfully did but in my excel file i got "2,345" as a string.So please suggest me how can i get "2,345" as a number value but with the same format as i used above(comma seperated).
Thanks in advance.
Remove the comma before inserting it into Excel, cast it to a number before inserting, then format the column to show the comma.
String replace
In Excel the code to format a Range with commas is:
SomeRange.Style = "Comma" 'or, recorded version
SomeRange.NumberFormat = "_-* #,##0_-;-* #,##0_-;_-* ""-""??_-;_-#_-"
'a simpler version..
SomeRange.NumberFormat = "#,##0"
I'm using JODReports to generate ODT files from templates. I want to fill a table with data so I used a JOOScript with Freemarker directives.
Now I want to conditionally format each row depending on my data:
#table:table-row
[#list rows as row]
[#if row.bar = "ipsum"]
[#assign rowcolor="#0000AA"]
[#else]
[#assign rowcolor="#000000"]
[/#if]
#/table:table-row
[/#list]
##table:table-cell
<What_Should_I_Put_Here_To_Color_The_Cell_Background_With_rowcolor?>
As you can see, if row.bar == "ipsum" I want the entire row be background-colored with #0000AA. Do you know a way (or an acceptable workaround) to achieve that?
Thank you.
We usually create table(say named MyStyleTable) in section and hide it. What we do with that table is set it's properties, for instance set background color for each cell, say A1 red, B1 green. And then assign appropriate MyStyleTable cell to your table(the one with data) cell properties:
#table:table-row
[#if row.bar = "ipsum"]
[#assign rowcolor='MyStyleTable.A1']
[#else]
[#assign rowcolor='MyStyleTable.B1']
[/#if]
#/table:table-row
##table:table-cell
table:style-name=${rowcolor}
I believe I've read there is a way to export style from contex.xml, and then assign style to whatever table or cell, but i haven't tried that.
I have Spring 3 MVC set up with Hibernate and MySQL 5. In a web form, I enter a single character into a field, € (i.e. just the one character). When I then attempt to save the data, I get the following exception:
java.sql.BatchUpdateException: Data truncation: Data truncated for column 'name' at row 1
'name' is a String on my model object. The 'name' column is of datatype VARCHAR(80) in MySQL. I have also tried entering a € into a TEXT column, with the same result.
I have configured a CharacterEncodingFilter for my webapp and my DB connection string looks like this:
jdbc:mysql://localhost/baseApp?zeroDateTimeBehavior=convertToNull&useUnicode=true&characterEncoding=utf8
Any ideas what the problem might be?
Update:
I don't think MySQL has anything to do with this issue. I have intercepted the HTTP POST before the properties of my model object are set and the € is properly encoded as %80. When I interrogate the properties of my model object, however, €'s are simply ?'s.
Any thoughts?
Are you sure the MySQL database suports UTF-8? I think the default install settings uses latin1. You also need to make sure that the 'default-character-set' for [mysql] and [mysqld] in the my.ini configuration file is set to 'utf8'. Furthermore make sure the table was built with UTF-8 settings.