Alphonse
Alphonse

Reputation: 3

How to export DataTable on Primefaces with .txt format?

I want to export a datatable in .txt form with a vertical bar ("|") separator.

Is there any sample code that can be used for this case? The showcase on primefaces is too complex and doesn't work for me.

Upvotes: 0

Views: 330

Answers (1)

Rapster
Rapster

Reputation: 524

You should be able to reuse csv exporter, and define attribute options of p:dataExporter with a new instance of CSVOptions. From there, you'll be able to define your own delimiter.

See a sample here https://primefaces.github.io/primefaces/11_0_0/#/components/dataexporter?id=customization

If txt extension is that important to you, maybe you can try to inherit from DataTableCSVExporter and override DataTableCSVExporter#getContentType and DataTableCSVExporter#getFileExtension methods

See a sample here https://primefaces.github.io/primefaces/11_0_0/#/components/dataexporter?id=custom-export

Upvotes: 1

Related Questions