列格式化cfspreadsheet

时间:2017-10-27 15:06:18

标签: coldfusion coldfusion-10 cfspreadsheet

我在ColdFusion 10中使用cfspreadheet。我正在将我的第5列对齐到右边。第1列至第44列右对齐,然后44至73再次开始对齐。这在尝试格式化电子表格时是否典型?

<cfset SpreadsheetFormatColumn( objSpreadsheet, {alignment="right"}, 5 )>

所有电子表格代码:

<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 SpreadsheetFormatColumn(objSpreadsheet, {alignment="right"}, 5 )>
    <cfset SpreadsheetFormatRow(objSpreadsheet, {bold=true, textwrap="true", alignment="center"}, 1 )>
    <cfloop list="#assocRows#" index="i">
      <cfset SpreadsheetFormatCell(objSpreadsheet, {'bold' : 'true'}, i, 1)>
    </cfloop>
    <!---<cfset spreadsheetFormatColumn( objSpreadsheet, {dataformat: "0.00%"}, 5 )>--->

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

如果我删除百分号,我应该添加&#39;%&#39;在十进制格式中,它完全对齐。但我试图让它与%符号一起使用。

0 个答案:

没有答案