Question

As subject title, when I try to export my data to a excel file then allow client user to download it. My code throw not supported mine type application/vnd.ms-excel.

Try with p:dataExporter, fail.

Try with p:fileDownload, fail.

I had some search and realize that primefaces file download and data exporter do not support liferay portal, maybe it still impossible until ver 6.1 ga1 ?

Is there any alternative solutions here please :-?

ps: I copy code from primefaces demo pages.

Was it helpful?

Solution

It is still possible, with the following workaround.

[Public StreamData getFile() {
  // 1. initialize the fileInputStream
  // 2. get Liferay's ServletResponse
  // 3. write the file into the outputStream
  // 4. return null to this method
}][1]

for more detail sample code, please refer http://kianworknotes.blogspot.com/2013/03/primefaces-filedownload-in-liferay.html#more

if you are using POI to generate the excel. in step 3, just write the following

workbook.write(outputstream)
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top