Logically change the style in pdf / excel export

Community Driven Extensions Project
Post Reply
swati.us.nj
Posts: 3
Joined: 19 Jan 2017, 06:10

19 Jan 2017, 06:27

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

Melloware
Posts: 3716
Joined: 22 Apr 2013, 15:48

19 Jan 2017, 14:15

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
PrimeFaces Developer | PrimeFaces Extensions Developer
GitHub Profile: https://github.com/melloware
PrimeFaces Elite 13.0.0 / PF Extensions 13.0.0
PrimeReact 9.6.1

swati.us.nj
Posts: 3
Joined: 19 Jan 2017, 06:10

20 Jan 2017, 07:57

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

Melloware
Posts: 3716
Joined: 22 Apr 2013, 15:48

20 Jan 2017, 14:15

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.
PrimeFaces Developer | PrimeFaces Extensions Developer
GitHub Profile: https://github.com/melloware
PrimeFaces Elite 13.0.0 / PF Extensions 13.0.0
PrimeReact 9.6.1

swati.us.nj
Posts: 3
Joined: 19 Jan 2017, 06:10

20 Jan 2017, 19:09

Thanks.
Can you please guide where I can get sample code for custom exporter.

Melloware
Posts: 3716
Joined: 22 Apr 2013, 15:48

20 Jan 2017, 19:36

PrimeFaces Developer | PrimeFaces Extensions Developer
GitHub Profile: https://github.com/melloware
PrimeFaces Elite 13.0.0 / PF Extensions 13.0.0
PrimeReact 9.6.1

Post Reply

Return to “Extensions”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 2 guests