ialonso Posted January 30, 2017 Share Posted January 30, 2017 I'm new with Jasper Reports. I'm using 5.6.0 version and I can export some data to PDF and all fields are filled correct but when I try to export the same data to Excel, some fields are missing. The code I use it's the some on both clases (I have one class for each file export)I also read that the template to export to PDF or Excel it's the same, so I don't know why fills all in PDF and not in Excel.When I generate the PDF I pass all the data to:JasperExportManager.exportReportToPdfStream(jasperPrint,fileOutputStream);[/code]And when I try to generate the Excel I call this funcion:private void generateExcel(JasperPrint jasperPrint) throws IOException, JRException { JRXlsExporter exporterXLS = new JRXlsExporter(); JFileChooser jFileChooser = new JFileChooser("."); jFileChooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); int status = jFileChooser.showOpenDialog(SIXACOPWorkbench.getWorkbenchContext().getWorkbench().getFrame()); if (status == JFileChooser.APPROVE_OPTION) { if (jFileChooser.getSelectedFile() != null) { String pathPDFs = (jFileChooser.getSelectedFile().getAbsolutePath()); File ficheroXLS = new File(pathPDFs+"//testing.xls"); FileOutputStream fos = new FileOutputStream(ficheroXLS); exporterXLS.setExporterInput(new SimpleExporterInput(jasperPrint)); exporterXLS.setExporterOutput(new SimpleOutputStreamExporterOutput(fos)); SimpleXlsReportConfiguration configuration = new SimpleXlsReportConfiguration(); configuration.setRemoveEmptySpaceBetweenRows(true); configuration.setDetectCellType(true); configuration.setWhitePageBackground(false); exporterXLS.setConfiguration(configuration); exporterXLS.exportReport(); fos.close(); } }}[/code]I think that if the template it's wrong the PDF must generate wrong but the output it's correct. And the code it's the same for both, only changes the call to the function that exports. So, what I'm doing wrong when exporting to Excel?Regards. Link to comment Share on other sites More sharing options...
szaharia Posted January 31, 2017 Share Posted January 31, 2017 Hi,Usually, this kind of errors are related to the report design. Overlapping elements in the report template are ignored in grid-layout-based exporters.Unlike PDF, the Excel exporter does not support the absolute positioning of the elements. In case elements are improperly aligned, some of them might be excluded from the export (see the explanation here). To solve this, create an appropriate layout for your report, ensure there are no overlapping or misaligned elements, and then run the report again.Regards,Sanda Link to comment Share on other sites More sharing options...
ialonso Posted February 1, 2017 Author Share Posted February 1, 2017 Hi @shertage, thanks for the link. I'm trying to make the report template again from a new black sheet but I can't find how make reports manually.Do you know some tutorial?Thanks! Link to comment Share on other sites More sharing options...
szaharia Posted February 2, 2017 Share Posted February 2, 2017 In case you are using the Jaspersoft Studio IDE, you can find several interesting tutorials and related documentation here:http://community.jaspersoft.com/project/jaspersoft-studio/resourcesRegards,Sanda Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now