1

I have a cellStyle created for the Excel file to have row striping. I also want to set any cells with numeric values to RIGHT ALIGN. I can accomplish this by checking the value of the cell, and if numeric I setCellStyle(styleRightAlign) where styleRightAlign is the name of my right align cellStyle.

However, this overrides the existing style and my cell no longer has the correct background color. It's right aligned correctly, but how can I just "add" a cell style rather than override the existing?

Is this possible?

I've looked at using the CellUtil setCellStyleProperty method but I'm unsure how to create an instance of this in ColdFusion, and if it is what I need for this.

UPDATE

So it looks like CF 11+ have the CellUtil available, but CF 10 does not. Figures. So I'm creating a separate style with my row striping for alignRight that includes the background color. If anyone has any ideas how I can just align the cell without affecting the existing cellStyle on it, I'd love to hear it.

Phil
  • 4,029
  • 9
  • 62
  • 107
  • Unfortunately if you do not want to modify the *existing* style, I think you just have to DIY in CF10. Since you are using a lot of functionality requiring a later version of POI, have you considered [running a newer version side by side](http://stackoverflow.com/questions/36482985/disable-excel-error-checking-through-coldfusion/36486725#36486725)? You should be able to do it using the rip of the JavaLoader.cfc that is baked into CF10+. – Leigh Jun 15 '16 at 16:36
  • Oops, wrong link. This one explains about loading a different version of a java library [using the Application.cfc settings](http://stackoverflow.com/questions/32001030/google-java-api-conflicted-with-coldfusion-cfhttp/32016842#32016842): – Leigh Jun 15 '16 at 17:02
  • @Leigh - I'm rather stuck on CF10 at the moment due to the client not wanting to change unless they absolutely have to. Thank you for all of your help, I've been able to get the Excel export working as intended and I would not have been able without your knowledge. – Phil Jun 15 '16 at 17:20
  • Glad I could help. Understood about upgrading, however the dynamic class loader feature is designed to let you load a different version of a jar(s) without having to upgrade. Just put the newer jars in a folder, load that folder path in your Application.cfc and away you go. It works well in *most* cases. Of course class loaders are *incredibly* picky, so once in a while you run into the old "jar hell" problem, but usually with specific libraries, such as older versions of dom4j. – Leigh Jun 15 '16 at 17:35
  • @Leigh - awesome, I was not aware I could do that. I'll check with my client to see if they'd like to give it a shot. Thanks again!! – Phil Jun 15 '16 at 18:04
  • (Edit) Sounds good. Assuming you have the CF Developer (or Express) version installed on your machine, you could also try out a small test yourself pretty quickly. Just as a POC. It will definitely allow access to both versions. The question is just will the it be simpler. – Leigh Jun 15 '16 at 18:07

0 Answers0