IDEMPIERE-2340 zk - Exporting reports as SSV generates CSV
This commit is contained in:
parent
ff3366bea9
commit
1e010fd936
|
@ -60,6 +60,7 @@ import net.sf.jasperreports.engine.JasperReport;
|
||||||
import net.sf.jasperreports.engine.design.JRDesignQuery;
|
import net.sf.jasperreports.engine.design.JRDesignQuery;
|
||||||
import net.sf.jasperreports.engine.design.JasperDesign;
|
import net.sf.jasperreports.engine.design.JasperDesign;
|
||||||
import net.sf.jasperreports.engine.export.JRCsvExporter;
|
import net.sf.jasperreports.engine.export.JRCsvExporter;
|
||||||
|
import net.sf.jasperreports.engine.export.JRCsvExporterParameter;
|
||||||
import net.sf.jasperreports.engine.export.JRHtmlExporter;
|
import net.sf.jasperreports.engine.export.JRHtmlExporter;
|
||||||
import net.sf.jasperreports.engine.export.JRPdfExporter;
|
import net.sf.jasperreports.engine.export.JRPdfExporter;
|
||||||
import net.sf.jasperreports.engine.export.JRPrintServiceExporter;
|
import net.sf.jasperreports.engine.export.JRPrintServiceExporter;
|
||||||
|
@ -714,8 +715,12 @@ public class ReportStarter implements ProcessCall, ClientProcess
|
||||||
exporter = new JRPrintServiceExporter(ljrContext);
|
exporter = new JRPrintServiceExporter(ljrContext);
|
||||||
else if (ext.equals("xml"))
|
else if (ext.equals("xml"))
|
||||||
exporter = new JRXmlExporter(ljrContext);
|
exporter = new JRXmlExporter(ljrContext);
|
||||||
else if (ext.equals("csv") || ext.equals("ssv"))
|
else if (ext.equals("csv"))
|
||||||
exporter = new JRCsvExporter(ljrContext);
|
exporter = new JRCsvExporter(ljrContext);
|
||||||
|
else if (ext.equals("ssv")) {
|
||||||
|
exporter = new JRCsvExporter(ljrContext);
|
||||||
|
exporter.setParameter(JRCsvExporterParameter.FIELD_DELIMITER, ";");
|
||||||
|
}
|
||||||
else if (ext.equals("txt"))
|
else if (ext.equals("txt"))
|
||||||
exporter = new JRTextExporter(ljrContext);
|
exporter = new JRTextExporter(ljrContext);
|
||||||
else if (ext.equals("html") || ext.equals("htm"))
|
else if (ext.equals("html") || ext.equals("htm"))
|
||||||
|
|
|
@ -468,12 +468,18 @@ public class WReportCustomization implements IFormController,EventListener<Even
|
||||||
m_reportEngine.createXML(sw);
|
m_reportEngine.createXML(sw);
|
||||||
data = sw.getBuffer().toString().getBytes();
|
data = sw.getBuffer().toString().getBytes();
|
||||||
}
|
}
|
||||||
else if (ext.equals("csv") || ext.equals("ssv"))
|
else if (ext.equals("csv"))
|
||||||
{
|
{
|
||||||
StringWriter sw = new StringWriter();
|
StringWriter sw = new StringWriter();
|
||||||
m_reportEngine.createCSV(sw, ',', m_reportEngine.getPrintFormat().getLanguage());
|
m_reportEngine.createCSV(sw, ',', m_reportEngine.getPrintFormat().getLanguage());
|
||||||
data = sw.getBuffer().toString().getBytes();
|
data = sw.getBuffer().toString().getBytes();
|
||||||
}
|
}
|
||||||
|
else if (ext.equals("ssv"))
|
||||||
|
{
|
||||||
|
StringWriter sw = new StringWriter();
|
||||||
|
m_reportEngine.createCSV(sw, ';', m_reportEngine.getPrintFormat().getLanguage());
|
||||||
|
data = sw.getBuffer().toString().getBytes();
|
||||||
|
}
|
||||||
else if (ext.equals("txt"))
|
else if (ext.equals("txt"))
|
||||||
{
|
{
|
||||||
StringWriter sw = new StringWriter();
|
StringWriter sw = new StringWriter();
|
||||||
|
|
|
@ -400,12 +400,18 @@ public class ReportAction implements EventListener<Event>
|
||||||
re.createXML(sw);
|
re.createXML(sw);
|
||||||
data = sw.getBuffer().toString().getBytes();
|
data = sw.getBuffer().toString().getBytes();
|
||||||
}
|
}
|
||||||
else if (ext.equals("csv") || ext.equals("ssv"))
|
else if (ext.equals("csv"))
|
||||||
{
|
{
|
||||||
StringWriter sw = new StringWriter();
|
StringWriter sw = new StringWriter();
|
||||||
re.createCSV(sw, ',', re.getPrintFormat().getLanguage());
|
re.createCSV(sw, ',', re.getPrintFormat().getLanguage());
|
||||||
data = sw.getBuffer().toString().getBytes();
|
data = sw.getBuffer().toString().getBytes();
|
||||||
}
|
}
|
||||||
|
else if (ext.equals("ssv"))
|
||||||
|
{
|
||||||
|
StringWriter sw = new StringWriter();
|
||||||
|
re.createCSV(sw, ';', re.getPrintFormat().getLanguage());
|
||||||
|
data = sw.getBuffer().toString().getBytes();
|
||||||
|
}
|
||||||
else if (ext.equals("txt"))
|
else if (ext.equals("txt"))
|
||||||
{
|
{
|
||||||
StringWriter sw = new StringWriter();
|
StringWriter sw = new StringWriter();
|
||||||
|
|
|
@ -14,6 +14,7 @@ import net.sf.jasperreports.engine.JRExporterParameter;
|
||||||
import net.sf.jasperreports.engine.JasperPrint;
|
import net.sf.jasperreports.engine.JasperPrint;
|
||||||
import net.sf.jasperreports.engine.JasperReport;
|
import net.sf.jasperreports.engine.JasperReport;
|
||||||
import net.sf.jasperreports.engine.export.JRCsvExporter;
|
import net.sf.jasperreports.engine.export.JRCsvExporter;
|
||||||
|
import net.sf.jasperreports.engine.export.JRCsvExporterParameter;
|
||||||
import net.sf.jasperreports.engine.export.JRHtmlExporter;
|
import net.sf.jasperreports.engine.export.JRHtmlExporter;
|
||||||
import net.sf.jasperreports.engine.export.JRHtmlExporterParameter;
|
import net.sf.jasperreports.engine.export.JRHtmlExporterParameter;
|
||||||
import net.sf.jasperreports.engine.export.JRPdfExporter;
|
import net.sf.jasperreports.engine.export.JRPdfExporter;
|
||||||
|
@ -57,7 +58,7 @@ public class ZkJRViewer extends Window implements EventListener<Event>, ITabOnCl
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
private static final long serialVersionUID = -8378226782387071338L;
|
private static final long serialVersionUID = -1250003381099609830L;
|
||||||
|
|
||||||
private JasperPrint jasperPrint;
|
private JasperPrint jasperPrint;
|
||||||
private Listbox previewType = new Listbox();
|
private Listbox previewType = new Listbox();
|
||||||
|
@ -103,6 +104,7 @@ public class ZkJRViewer extends Window implements EventListener<Event>, ITabOnCl
|
||||||
previewType.appendItem("HTML", "HTML");
|
previewType.appendItem("HTML", "HTML");
|
||||||
previewType.appendItem("Excel", "XLS");
|
previewType.appendItem("Excel", "XLS");
|
||||||
previewType.appendItem("CSV", "CSV");
|
previewType.appendItem("CSV", "CSV");
|
||||||
|
previewType.appendItem("SSV", "SSV");
|
||||||
if ("PDF".equals(defaultType)) {
|
if ("PDF".equals(defaultType)) {
|
||||||
previewType.setSelectedIndex(0);
|
previewType.setSelectedIndex(0);
|
||||||
} else if ("HTML".equals(defaultType)) {
|
} else if ("HTML".equals(defaultType)) {
|
||||||
|
@ -111,6 +113,8 @@ public class ZkJRViewer extends Window implements EventListener<Event>, ITabOnCl
|
||||||
previewType.setSelectedIndex(2);
|
previewType.setSelectedIndex(2);
|
||||||
} else if ("CSV".equals(defaultType)) {
|
} else if ("CSV".equals(defaultType)) {
|
||||||
previewType.setSelectedIndex(3);
|
previewType.setSelectedIndex(3);
|
||||||
|
} else if ("SSV".equals(defaultType)) {
|
||||||
|
previewType.setSelectedIndex(4);
|
||||||
} else {
|
} else {
|
||||||
previewType.setSelectedIndex(0);
|
previewType.setSelectedIndex(0);
|
||||||
log.info("Format not Valid: "+defaultType);
|
log.info("Format not Valid: "+defaultType);
|
||||||
|
@ -126,6 +130,8 @@ public class ZkJRViewer extends Window implements EventListener<Event>, ITabOnCl
|
||||||
previewType.setSelectedIndex(0); // default to PDF if cannot export
|
previewType.setSelectedIndex(0); // default to PDF if cannot export
|
||||||
} else if ("CSV".equals(defaultType)) {
|
} else if ("CSV".equals(defaultType)) {
|
||||||
previewType.setSelectedIndex(0); // default to PDF if cannot export
|
previewType.setSelectedIndex(0); // default to PDF if cannot export
|
||||||
|
} else if ("SSV".equals(defaultType)) {
|
||||||
|
previewType.setSelectedIndex(0); // default to PDF if cannot export
|
||||||
} else {
|
} else {
|
||||||
previewType.setSelectedIndex(0);
|
previewType.setSelectedIndex(0);
|
||||||
log.info("Format not Valid: "+defaultType);
|
log.info("Format not Valid: "+defaultType);
|
||||||
|
@ -292,6 +298,23 @@ public class ZkJRViewer extends Window implements EventListener<Event>, ITabOnCl
|
||||||
exporter.exportReport();
|
exporter.exportReport();
|
||||||
|
|
||||||
media = new AMedia(m_title, "csv", "application/csv", file, true);
|
media = new AMedia(m_title, "csv", "application/csv", file, true);
|
||||||
|
|
||||||
|
}else if ("SSV".equals(reportType)) {
|
||||||
|
String path = System.getProperty("java.io.tmpdir");
|
||||||
|
String prefix = makePrefix(jasperPrint.getName());
|
||||||
|
if (log.isLoggable(Level.FINE))
|
||||||
|
{
|
||||||
|
log.log(Level.FINE, "Path="+path + " Prefix="+prefix);
|
||||||
|
}
|
||||||
|
File file = File.createTempFile(prefix, ".ssv", new File(path));
|
||||||
|
FileOutputStream fos = new FileOutputStream(file);
|
||||||
|
JRCsvExporter exporter= new JRCsvExporter();
|
||||||
|
exporter.setParameter(JRCsvExporterParameter.FIELD_DELIMITER, ";");
|
||||||
|
exporter.setParameter(JRExporterParameter.JASPER_PRINT, jasperPrint);
|
||||||
|
exporter.setParameter(JRExporterParameter.OUTPUT_STREAM, fos);
|
||||||
|
exporter.exportReport();
|
||||||
|
|
||||||
|
media = new AMedia(m_title, "ssv", "application/ssv", file, true);
|
||||||
}
|
}
|
||||||
} finally {
|
} finally {
|
||||||
Thread.currentThread().setContextClassLoader(cl);
|
Thread.currentThread().setContextClassLoader(cl);
|
||||||
|
|
|
@ -948,12 +948,18 @@ public class ZkReportViewer extends Window implements EventListener<Event>, ITab
|
||||||
m_reportEngine.createXML(sw);
|
m_reportEngine.createXML(sw);
|
||||||
data = sw.getBuffer().toString().getBytes();
|
data = sw.getBuffer().toString().getBytes();
|
||||||
}
|
}
|
||||||
else if (ext.equals("csv") || ext.equals("ssv"))
|
else if (ext.equals("csv"))
|
||||||
{
|
{
|
||||||
StringWriter sw = new StringWriter();
|
StringWriter sw = new StringWriter();
|
||||||
m_reportEngine.createCSV(sw, ',', m_reportEngine.getPrintFormat().getLanguage());
|
m_reportEngine.createCSV(sw, ',', m_reportEngine.getPrintFormat().getLanguage());
|
||||||
data = sw.getBuffer().toString().getBytes();
|
data = sw.getBuffer().toString().getBytes();
|
||||||
}
|
}
|
||||||
|
else if (ext.equals("ssv"))
|
||||||
|
{
|
||||||
|
StringWriter sw = new StringWriter();
|
||||||
|
m_reportEngine.createCSV(sw, ';', m_reportEngine.getPrintFormat().getLanguage());
|
||||||
|
data = sw.getBuffer().toString().getBytes();
|
||||||
|
}
|
||||||
else if (ext.equals("txt"))
|
else if (ext.equals("txt"))
|
||||||
{
|
{
|
||||||
StringWriter sw = new StringWriter();
|
StringWriter sw = new StringWriter();
|
||||||
|
|
Loading…
Reference in New Issue