Skip to main content
Inspiring
January 26, 2023
Question

Set excel cell color with javascript created with cfspreadsheet

  • January 26, 2023
  • 2 replies
  • 1844 views

I've create a excel file with CFSpreadSheet and now I want to change the color of a cell to a hexcolor that is not available with CFSpreadSheet.  Can it be done with javascript?

 

<cfset xl = spreadsheetNew("Hazard Details",true)>

<cfset SpreadsheetAddRow(xl,"Test")>

<cfset SpreadsheetFormatCell(xl,{color="red",bold="true"},#xl.rowcount#,1)>

 

Will set it to red.  But I want to use a color that is not available with cfspreadsheet like hexcolor #355f91

something like:

<cfset SpreadsheetFormatCell(xl,{color="#355f91",bold="true"},#xl.rowcount#,1)>

    This topic has been closed for replies.

    2 replies

    EddieLotter
    Inspiring
    January 26, 2023

    This StackOverflow post apparently shows how to do it in ColdFusion.

    Charlie Arehart
    Community Expert
    Community Expert
    January 26, 2023

    So there you go, Robert, on the "someone else may chime in with a better answer".  And thanks, Eddie.

     

    Though do read all the answers, Robert. You may need the last one. And it's all a pretty ugly way to achieve the goal, but if you must, it seems it should work.

     

    Eddie, can you confirm that it worked for you? If so, what cf version? And Robert, if somehow it doesn't, what cf version are you running? 

    /Charlie (troubleshooter, carehart. org)
    EddieLotter
    Inspiring
    January 26, 2023

    Charlie, I have not had a need to do this, so have not tried it. I leave it as an excercise for the OP. 🙂

    Charlie Arehart
    Community Expert
    Community Expert
    January 26, 2023

    Robert, two things. First, no, you would NOT be able to control how any cfml tag works via Javascript. As you may know, that's a client-side language, and cfml is entirely a server-side language. Second, I realize you're just very much wanting that hex level of color control, and so you are open to any possibility. I just don't think there is one. 

     

    I know you asked about this prospect of using hex colors with cfspreadsheet a couple of weeks ago, and FWIW I didn't answer then as I didn't see that it was possible. I looked into it quite a bit, and tried things, all to no avail. I didn't say anything then as I hoped perhaps someone else might. They did not, I now see. So I am offering this now, lest you think no one is paying any attention. Sorry it's not the solution, but at least it's an answer. Perhaps someone else may chime in with a better one. 

     

    (BTW, you've opened this new question rather than adding your new js idea as a comment there. Perhaps you thought this might get better attention, but that's not my experience. Either would cause the thread to appear at the top of the web ui, and either would generate an email to those who choose to get such notifications--like I do.) 

    /Charlie (troubleshooter, carehart. org)