Skip to main content
DevScreen
Inspiring
July 10, 2025
Answered

Help with XSSFColor after the latest update

  • July 10, 2025
  • 1 reply
  • 624 views

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.
    Correct answer DevScreen

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

    1 reply

    DevScreen
    DevScreenAuthorCorrect answer
    Inspiring
    July 10, 2025

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

    BKBK
    Community Expert
    July 15, 2025

    Thanks for sharing your solution.