Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
2

Help with XSSFColor after the latest update

Explorer ,
Jul 10, 2025 Jul 10, 2025

For excel files, we use Apache POI.  It worked fine until we applied the latest CF Security patch to our CF2023 server.  It must have updated POI to the latest version which deprecated some of the functions.  I was able to fix one issue, but am not able to see how I can create XSSFColor from RGB.  My previous code was:

rgb=createObject("java","java.awt.Color").init(javacast("int",234),javacast("int",230),javacast("int",202));
createObject("java","org.apache.poi.xssf.usermodel.XSSFColor").init(rgb);
This used to create a color from Red=234, Green=230, and Blue=202, but now it crashes because the init function needs more arguments.
 
I need to now pass RGB in "Byte Array" such as: XSSFColor(byte[] rgb) . I am not sure how to make a byte array in coldfusion. I have tried this:
javaCast("byte[]",
        [
            javaCast( "byte", 234),
            javaCast( "byte", 230),
            javaCast( "byte", 202)
        ]);
This doesn't work because CF says: Cannot convert the value 255.0 to byte because it cannot fit inside a byte.
In java, you can say: byte[0] = (byte) 234 and it could work, but CF is not letting it through.
 
Can anyone point in the right direction? My goal is to make XSSFColor work again using RGB values.
 
 
I have found the solution.  Below is what I did, incase it helps anyone with similar issue.
 
If you want to create a color of RGB, for example, where R=234, G=230, B=202, you have to feed a byte array into XSSFColor.  To do this, you can use ByteArrayOutputStream as follows:
rgbStream = CreateObject( "java", "java.io.ByteArrayOutputStream" ).init(javacast("int",3)); //argument is optional
rgbStream.write(javaCast("int",234));
rgbStream.write(javaCast("int",230));
rgbStream.write(javaCast("int",202));
Once the stream is created, you can pass it onto XSSFColor like this:
createObject("java","org.apache.poi.xssf.usermodel.XSSFColor").init(rgbStream.toByteArray())
 
If you wish to re-use rgbStream, you can do rgbStream.reset(), and write() new values to it.
471
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Explorer , Jul 10, 2025 Jul 10, 2025

I found the solution after doing lots of research, and have posted it above in my original post incase it helps someone.

Translate
Explorer ,
Jul 10, 2025 Jul 10, 2025

I found the solution after doing lots of research, and have posted it above in my original post incase it helps someone.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jul 15, 2025 Jul 15, 2025

Thanks for sharing your solution.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jul 23, 2025 Jul 23, 2025

We ended up not needing the color code we had but this took us in the right direction. Thanks for posting your solution!

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jul 23, 2025 Jul 23, 2025
LATEST

Glad to hear it helped steer you in the right direction 🙂 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources