cfspreadsheet使行中的第一项加粗

时间:2017-10-27 12:25:08

标签: coldfusion coldfusion-10 cfspreadsheet

我在ColdFusion10中使用cfspreadsheet有一个行列表。

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

我试图将这部分加粗。

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

我已经尝试过cfif语句,似乎没有任何东西可以让我得到我的名字大胆的结果。

对此的任何帮助将不胜感激。

修改

我的整个电子表格

<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>

1 个答案:

答案 0 :(得分:1)

包含所有行后,您可以使用以下内容。

<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>