Jump to content
We've recently updated our Privacy Statement, available here ×

Excel export creates unwanted cell merges, especially in subreports


drummer54

Recommended Posts

I have reports that must be included in sets, thus the use of subreports, and that must be exported to Excel so that our CEO and clients can sort the data to their liking.  I've been able to mostly remove unwanted cell merging using the net.sf.jasperreports.export.xls.column.width property, but only when exporting the report as the main report.  When the report is included as a subreport and exported the numerous unwanted cell merges occur.  Is there any way to rectify this?

Image of report exported as subreport:

ScreenShot2015-05-07at11_16_33AM.png.48d9f7e461bff0094c22f3b3a66272c9.png

Image of report exported as main report, with manageable cell merges:

ScreenShot2015-05-07at11_18_19AM.png.1ee4661460e9a5fa38af52d155cb795f.png

Link to comment
Share on other sites

  • Replies 3
  • Created
  • Last Reply

Top Posters In This Topic

I couldn't see a problem on the files you attached - although it's hard to paste files on here.

Mergin of cells is mostly down to bad report design.

If your using subreports, try to plan ahead and use the same size column widths and make sure you allign the subreports in sync in your master.  Excel will create a merge of cells if any of cells in your reports overlap.

For example if in main report column 1 has width of 100, col2 width 100 and in subreport 1 column 1 has width of 50, col 1 width 100 this will cause a merge to occur in excel because your reports are not alligned.

 

Hope this helps

Link to comment
Share on other sites

So it affects subreports in Excel even if the subreports are saved to different worksheets?  What if the data being presented in each report doesn't lend itself to identical column widths?  SQL Server Reporting Services doesn't have this problem.  Not that I think it's an especially good tool, because it has a lot of faults, but it does handle creation of Excel columns well.

The only way I have figured out how to mitigate this effect is to move all of my column headings into the title bar, make a single field with the date/time and place it over a data column that is the same width as the date/time field, and make certain that the report title is the same width as the data column under it.  All of this seems to be an unnecessary restriction - again, SSRS handles this quite well.  Our standard is that the report title is placed at the top left and the date/time is placed at the top right of the report.  If I have a long report title (and we have many that are rather lengthy) or a right most data column that is very narrow (narrower than required by the date/time stamp), it fouls up the cells when exporting to Excel.  Or we define cell widths just to accommodate this "bad programming" (vs bad report design) whether it fits the data or not.

Link to comment
Share on other sites

  • 2 weeks later...

I have to say it is really ridiculous that the subreports have to have the same number of columns and that the columns all have to be the same width to get this to work properly.  I've also tried using tables to achieve this and the behavior is the same - if the tables either have a different number of columns or if the column widths differ then you get merged cells that prevent the user from sorting, even though each table, as is the case with the subreports, is being saved to a different worksheet.  SSRS can handle this so I don't see where it's a fault of Excel, it's something in JasperReports.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...