Jump to content

Problem for Excel data Exporting layout


parthbhagat

Recommended Posts

Hi All,

 

I am using jasperreports 3.7.1. In that I am trying to export my data in .xls format using JExcelApiExporter. Export is working fine. What I want is the functionality of Microsoft Excel's grouping of data. As in Excel, by selecting entries to be grouped, go to Data -> Group & select row or column, & then you will see collapse button for that many of rows/columns on left most side. Please find the attached image for more detail. I am trying to do the same in the report. But not done yet. Can any one help me out?

 

Thanking you,

Parth Bhagat.

Link to comment
Share on other sites

  • Replies 2
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

Hi Teodor,

 

Thank you for the reply.

I tried this with Jasper Reports, but not found anything for row grouping in Excel. I think this functionality is not implemented with Jasper Reports 3.7.4. But I found an alternate way to do the same.

I used POI APIs for row grouping of data in Excel. It provides simple way to group, but very tedious designs of reports in it.

Here is the code for that with POI.

Please provide me the feedback regarding this.

 

Thanking you,

Parth Bhagat.

Code:
JExcelApiExporter exporterXLS = new JExcelApiExporter();exporterXLS.setParameter(JRXlsExporterParameter.JASPER_PRINT, jasperPrint);exporterXLS.setParameter(JRXlsExporterParameter.IS_DETECT_CELL_TYPE, Boolean.TRUE);exporterXLS.setParameter(JRXlsExporterParameter.IS_WHITE_PAGE_BACKGROUND, Boolean.FALSE);exporterXLS.setParameter(JRXlsExporterParameter.IS_REMOVE_EMPTY_SPACE_BETWEEN_ROWS, Boolean.TRUE);ByteArrayOutputStream output = new ByteArrayOutputStream();exporterXLS.setParameter(JExcelApiExporterParameter.OUTPUT_STREAM, output);exporterXLS.exportReport();bytes = output.toByteArray();HSSFWorkbook xlsFile = new HSSFWorkbook(new ByteArrayInputStream(bytes));HSSFSheet sheet = xlsFile.getSheetAt(0);sheet.groupRow(fromRowIndex, toRowIndex);sheet.setRowGroupCollapsed(fromRowIndex, true);FileOutputStream rowGroupFileOutputStream = new FileOutputStream();xlsFile.write(rowGroupFileOutputStream);
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...