Page 1 of 1

Logically change the style in pdf / excel export

Posted: 19 Jan 2017, 06:27
by swati.us.nj
Hi,

Can some one kindly provide an example / guidance for following requirement.

I am working on creating a report which needs to be exported to pdf / excel.
The font colors on certain table headers and some rows need to be red, and the rest default.

The content on webpage are done accordingly (headers and some rows in red). However, when export to pdf (or excel) is clicked, it creates pdf (or excel) it does not carry forward those colors and shows everything in default color (black). I want exactly same styles (font colors) to be reflected in exported pdf / excel.

Thanks in advance.
Swati

Re: Logically change the style in pdf / excel export

Posted: 19 Jan 2017, 14:15
by Melloware
You want to look at this example which lets you change the colors and fonts of the output PDF of XLSX. It lets you style headers and footers and cells etc.

http://www.primefaces.org/showcase-ext/ ... tTable.jsf

Re: Logically change the style in pdf / excel export

Posted: 20 Jan 2017, 07:57
by swati.us.nj
Thanks Melloware for reply.

Will this method allow me to get different colors for text in different cells?
I intend to have different colors for text in one row and a different in another one.

With regards to your link, I have few questions.

- Where is the mapping for target="#{exporterController.customExporter}"?
- How do we define this mapping so as to link to my custom class - CustomPDFExporter, which extends PDFExporter and, say, overrides addColumnFacets.

Within addColumnFacets, I intend to add color related logic.

Please validate if my approach is right?

Thanks
Swati

Re: Logically change the style in pdf / excel export

Posted: 20 Jan 2017, 14:15
by Melloware
Its all in that example link I sent. See you can change the facet and cell colors.

However if you need to change per cell I think you will need to write your own custom Exporter if you need finer grain control than that.

Re: Logically change the style in pdf / excel export

Posted: 20 Jan 2017, 19:09
by swati.us.nj
Thanks.
Can you please guide where I can get sample code for custom exporter.

Re: Logically change the style in pdf / excel export

Posted: 20 Jan 2017, 19:36
by Melloware