I need to store the exported data into some file as string or as excel format and I want to send that file using email.
my current export statement is
<p:dataExporter type="xls" target="tableWbTicketold" fileName="TicketOldReport" />
you have two alternatives:
use postProcessor: <p:dataExporter type="xls" target="tbl" fileName="cars" postProcessor="#{tableBean.postProcessXLS}"/>
.
you can email the WorkBook inside tableBean.postProcessXLS
, but this will not prevent the normal flow (file download dialog)
write your own DataExporter
custom component extending PF classes and overriding: DataExporter.processAction
, ExcelExporter.export
UPDATE
this way:
public void postProcessXLS(Object document)
{
try
{
Workbook wb = (Workbook) document;
File file = File.createTempFile("exporter-", ".xls");
FileOutputStream out = new FileOutputStream(file);
wb.write(out); // or write in mail body
out.close();
// do what you need with file
file.delete();
}
catch(IOException e)
{
e.printStackTrace();
}
}