coldfusioncoldfusion-10cfspreadsheet

cfspreadsheet making first item in row bold


I have a rowlist using cfspreadsheet in ColdFusion10.

<cfset rowList = "'#(rnA eq 1)?assoc_name:''#','#(rnl eq 1)?trans_location:''#','#checklistsByAssocLoc#','#assocChecklistsByLoc#','#DecimalFormat(totalChecklistsByAssocLocPct)#'">

I am trying to make this portion bold.

'#(rnA eq 1)?assoc_name:''#',

I have tried cfif statements and nothing seems to give me the result I need to make my names bold.

Any help with this would be greatly appreciated.

EDIT

My entire spreadsheet

<cftry>

<cfset objSpreadsheet = SpreadsheetNew()>

<!--- Create and format the header row. --->
<cfset SpreadsheetAddRow( objSpreadsheet, "Associate Name,Location,Checklists Generated by Associate,Checklists Generated by Selected Location(s),Associate Percentage of Location Total" )>
<cfset SpreadsheetFormatRow( objSpreadsheet, {bold=true, textwrap="true", alignment="center"}, 1 )>

<cfset rowNumber = 0 />
<cfoutput query="GetEmployeeInfo">
    <cfset rowNumber++ />
    <cfset rowList = "'#(rnA eq 1)?assoc_name:''#','#(rnl eq 1)?trans_location:''#','#checklistsByAssocLoc#','#assocChecklistsByLoc#','#DecimalFormat(totalChecklistsByAssocLocPct)#'">
    <cfset SpreadsheetAddRow( objSpreadsheet, rowList)>
    <cfset SpreadsheetFormatColumn(objSpreadsheet, {'bold' : 'true'}, 1)>
    <!---<cfset spreadsheetFormatCell( objSpreadsheet, {bold: true}, rowNumber, 1 )>--->
    <cfif rnTotAssoc EQ 1>
        <cfset rowNumber++ />
        <cfset rowList = "'Associate Total','','#totalChecklistsByAssoc#','#totalAssocChecklistsByAllFilteredLoc#','#DecimalFormat(totalChecklistsByLocPct)#'" >
        <cfset SpreadsheetAddRow( objSpreadsheet, rowList )>
    </cfif>
</cfoutput>

<cfset SpreadSheetSetColumnWidth(objSpreadsheet,1,25)> 
<cfset SpreadSheetSetColumnWidth(objSpreadsheet,2,25)>
<cfset SpreadSheetSetColumnWidth(objSpreadsheet,3,25)>
<cfset SpreadSheetSetColumnWidth(objSpreadsheet,4,25)>
<cfset SpreadSheetSetColumnWidth(objSpreadsheet,5,25)>

<cfheader name="Content-Disposition" value="inline; filename=CS_#Dateformat(NOW(),'MMDDYYYY')#.xls"> 
<cfcontent type="application/vnd.ms-excel" variable="#SpreadsheetReadBinary( objSpreadsheet )#">

<cfcatch type = "any">
        #rowList#
        <cfabort>
    </cfcatch>
</cftry>

Solution

  • You can use the following after all the rows are included.

    <cftry>
    
        <cfset objSpreadsheet = SpreadsheetNew()>
        <cfset assocRows = ''>
    
        <!--- Create and format the header row. --->
        <cfset SpreadsheetAddRow( objSpreadsheet, "Associate Name,Location,Checklists Generated by Associate,Checklists Generated by Selected Location(s),Associate Percentage of Location Total" )>
    
        <cfset rowNumber = 1 />
        <cfoutput query="GetEmployeeInfo">
            <cfset rowNumber++ />
            <cfset rowList = "'#(rnA eq 1)?assoc_name:''#','#(rnl eq 1)?trans_location:''#','#checklistsByAssocLoc#','#assocChecklistsByLoc#','#DecimalFormat(totalChecklistsByAssocLocPct)#'">
            <!--- Make list of rows --->
            <cfif (rnA eq 1)>
              <cfset assocRows = ListAppend(assocRows, rowNumber)>
            </cfif>
            <cfset SpreadsheetAddRow( objSpreadsheet, rowList)>
            <cfif rnTotAssoc EQ 1>
                <cfset rowNumber++ />
                <cfset rowList = "'Associate Total','','#totalChecklistsByAssoc#','#totalAssocChecklistsByAllFilteredLoc#','#DecimalFormat(totalChecklistsByLocPct)#'" >
                <cfset SpreadsheetAddRow( objSpreadsheet, rowList )>
            </cfif>
        </cfoutput>
    
        <cfset SpreadSheetSetColumnWidth(objSpreadsheet,1,25)> 
        <cfset SpreadSheetSetColumnWidth(objSpreadsheet,2,25)>
        <cfset SpreadSheetSetColumnWidth(objSpreadsheet,3,25)>
        <cfset SpreadSheetSetColumnWidth(objSpreadsheet,4,25)>
        <cfset SpreadSheetSetColumnWidth(objSpreadsheet,5,25)>
        <!--- Move the line here --->
        <cfset SpreadsheetFormatRow( objSpreadsheet, {bold=true, textwrap="true", alignment="center"}, 1 )>
        <cfloop list="#assocRows#" index="i">
          <cfset SpreadsheetFormatCell(objSpreadsheet, {'bold' : 'true'}, i, 1)>
        </cfloop>
    
        <cfheader name="Content-Disposition" value="inline; filename=CS_#Dateformat(NOW(),'MMDDYYYY')#.xls"> 
        <cfcontent type="application/vnd.ms-excel" variable="#SpreadsheetReadBinary( objSpreadsheet )#">
    
        <cfcatch type = "any">
            #rowList#
            <cfabort>
        </cfcatch>
    </cftry>