Skip to main content
Inspiring
January 9, 2023
Question

Format part of a cell with CFSpreadSheet

  • January 9, 2023
  • 3 replies
  • 1327 views

I would like to be able to format part of a cell so that the output looks like:

Updated for SSEWG: Yes Date: 8/31/2022

instead of having to put each section into a different cell like:

Updated for SSEWG:YesDate:31-Aug-2022                
    This topic has been closed for replies.

    3 replies

    Inspiring
    January 9, 2023

    Using ColdFusion CFSpreadSheet to format part of a cell.

    Charlie Arehart
    Community Expert
    January 9, 2023

    Robert, you can help us help you by showing what sort of code first puts those values into those cells. 

     

    For instance, if it's using SpreadSheetAddRows(), which puts query results into a sheet, you could control a single column being comprised of text (formatted) and data by way of the sql SELECT statement.

     

    Or if you have no such control over how the sheet is populated, note that there's a function to merge cells, spreadsheet merge cells.

     

    Or perhaps in seeing your code, we may have still other suggestions.

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

    That is ColdFusion code, however, be sure to put it in a cfscript block.


    I must be missing something.  Here is the code I'm using so far:

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

    <cfset SpreadsheetAddRow(xl,"")>

     

    <cfscript>

    wb = xl.getWorkbook();

    Colors = createObject("java", "org.apache.poi.ss.usermodel.IndexedColors");

    greenFont = wb.createFont();

    greenFont.setColor(Colors.GREEN.index);

    blueFont = wb.createFont();

    blueFont.setColor(Colors.BLUE.index);

    // Using GREEN and BLUE for demo purposes

    richString = createObject("java", "org.apache.poi.xssf.usermodel.XSSFRichTextString").init();

    richString.append("Text1: ", greenFont);

    richString.append("Text2", blueFont);

    cell = wb.getSheet("Sheet1").getRow( xl.rowcount ).getCell( 1 );

    cell.setCellValue(richString);

    </cfscript>

     

    I get an erorr:

    The append method was not found.

    And what would be the statement to change to BOLD instead of changing the color?

    blueFont.setColor(Colors.BLUE.index); 

    to

    boldFont.setBold = True (is this correct?)

    kglad
    Community Expert
    January 9, 2023

    in the future, to find the best place to post your message, use the list here, https://community.adobe.com/

     

    p.s. i don't think the adobe website, and forums in particular, are easy to navigate, so don't spend a lot of time searching that forum list. do your best and we'll move the post if it helps you get responses.

     

    <moved from using the community>

    Peru Bob
    Community Expert
    January 9, 2023

    This is the Using the Community forum (which is the forum for issues using the forums).
    Please tell us what Adobe application you are using so that this can be moved to the proper forum for help.