-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
OLMIS-8075: Add support for XLSX format in report generation
- Loading branch information
1 parent
221f74d
commit 4d8c807
Showing
6 changed files
with
60 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
43 changes: 43 additions & 0 deletions
43
src/main/java/org/openlmis/report/service/JasperXlsxExporter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
/* | ||
* This program is part of the OpenLMIS logistics management information system platform software. | ||
* Copyright © 2020 VillageReach | ||
* | ||
* This program is free software: you can redistribute it and/or modify it under the terms | ||
* of the GNU Affero General Public License as published by the Free Software Foundation, either | ||
* version 3 of the License, or (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; | ||
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | ||
* See the GNU Affero General Public License for more details. You should have received a copy of | ||
* the GNU Affero General Public License along with this program. If not, see | ||
* http://www.gnu.org/licenses. For additional information contact [email protected]. | ||
*/ | ||
|
||
package org.openlmis.report.service; | ||
|
||
import java.io.ByteArrayOutputStream; | ||
import net.sf.jasperreports.engine.JRException; | ||
import net.sf.jasperreports.engine.JasperPrint; | ||
import net.sf.jasperreports.engine.export.ooxml.JRXlsxExporter; | ||
import net.sf.jasperreports.export.SimpleExporterInput; | ||
import net.sf.jasperreports.export.SimpleOutputStreamExporterOutput; | ||
|
||
public class JasperXlsxExporter implements JasperExporter { | ||
|
||
private final JasperPrint jasperPrint; | ||
|
||
JasperXlsxExporter(JasperPrint jasperPrint) { | ||
this.jasperPrint = jasperPrint; | ||
} | ||
|
||
@Override | ||
public byte[] exportReport() throws JRException { | ||
ByteArrayOutputStream baos = new ByteArrayOutputStream(); | ||
JRXlsxExporter exporter = new JRXlsxExporter(); | ||
|
||
exporter.setExporterInput(new SimpleExporterInput(jasperPrint)); | ||
exporter.setExporterOutput(new SimpleOutputStreamExporterOutput(baos)); | ||
exporter.exportReport(); | ||
return baos.toByteArray(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters