我有一段代码,为发票设置“Aging”值,作为导出到excel脚本的一部分。除了“Aging”值之外,导出功能中的所有其他选项都有效。
以下是“老化”工作原理的SQL代码:
<cfif Aging neq "">
<cfswitch expression="#Aging#">
<cfcase value=29>
AND I.DueDate BETWEEN dateadd(day, datediff(day, 0 ,getdate())-29, 0) AND dateadd(day, datediff(day, 0 ,getdate()), 0)
AND I.OutstandingAmount > 0
</cfcase>
<cfcase value=59>
AND I.DueDate BETWEEN dateadd(day, datediff(day, 0 ,getdate())-59, 0) AND dateadd(day, datediff(day, 0 ,getdate())-30, 0)
AND I.OutstandingAmount > 0
</cfcase>
<cfcase value=89>
AND I.DueDate BETWEEN dateadd(day, datediff(day, 0 ,getdate())-89, 0) AND dateadd(day, datediff(day, 0 ,getdate())-60, 0)
AND I.OutstandingAmount > 0
</cfcase>
<cfcase value=90>
AND I.DueDate < dateadd(day, datediff(day, 0 ,getdate())-90, 0)
AND I.OutstandingAmount > 0
</cfcase>
</cfswitch>
</cfif>
我是ColdFusion的新手,我无法弄清楚如何编写Excel部分的代码。这是导出功能,为了便于阅读,添加了换行符。
<!--- ------------------------------------------ --->
<cfelseif ExType eq "xls5">
<!--- ------------------------------------------ --->
<cfset tabchar = Chr(9)>
<cfset NewLine = Chr(13) & Chr(10)>
<cfcontent type="text/msexcel">
<cfheader name="Content-Disposition" value="Attachment; filename=Late/Aging.xls">
<cfoutput>DATE INVOICED#TabChar#INVOICE#TabChar#CLIENT#TabChar#TOTAL#TabChar#AMOUNT DUE#TabChar#AGE#NewLine#</cfoutput>
<cfoutput query="viewinvoices">
<cfif curr.currencytype eq "Euro">
<cfset TotalC = #LSEuroCurrencyFormat(TotalCost, "local")#>
<cfelse>
<CFSET oldlocale = SetLocale(#curr.currencytype#)>
<cfset TotalC = #LSCurrencyFormat(TotalCost, "local")#>
</cfif>
<cfif curr.currencytype eq "Euro">
<cfset OutAmt = #LSEuroCurrencyFormat(OutstandingAmount, "local")#>
<cfelse>
<CFSET oldlocale = SetLocale(#curr.currencytype#)>
<cfset OutAmt = #LSCurrencyFormat(OutstandingAmount, "local")#>
</cfif>
#DateFormat(InvoiceDate, 'mm/dd/yyyy')##TabChar#
<cfif curr.CustomInvoices eq "0">
#Invoice#
<cfelse>
#NumberFormat(InvoiceCustom, '0000')#
</cfif>
#TabChar##Client##TabChar##TotalC##TabChar##OutAmt##TabChar##Aging##Newline#
</cfoutput>
我的导出声明中有这个,但似乎不起作用:
<cfif Aging eq "29">
<cfset Aging = 'Year(s)'>
<cfelseif Aging eq "59">
<cfset Aging = 'Day(s)'>
<cfelseif Aging eq "89">
<cfset Aging = 'Month(s)'>
<cfelseif Aging eq "90">
<cfset Aging = 'Quarter(s)'>
<cfelse>
<cfset Aging = 'n/a'>
</cfif>
文本年份等只是用于测试。