我继承了一个页面,该页面从四个表构建库存查询并使用 QoQ 输出它们:
<cfoutput query="getParts">
<cfquery dbtype="query" name="jobdata">
select *
from getJobs
where partnum = '#getparts.partnum#'
</cfquery>
<cfquery dbtype="query" name="orderdata">
select *
from getOrders
where partnum = '#getparts.partnum#'
</cfquery>
<cfquery dbtype="query" name="receiptdata">
select *
from getIncoming
where partnum = '#getparts.partnum#'
</cfquery>
<tr>
<td>#partnum#</td>
<td align="center">#partdescription#</td>
<td align="center">#allocated#</td>
<td align="center">#onhand#</td>
<td align="center">#receiptdata.recqty#</td>
<td align="center">#jobdata.JobCount#</td>
<td align="center">#jobdata.QtyNeeded#</td>
<td align="center">#jobdata.qtySent#</td>
<td align="center">#orderdata.ordercount#</td>
<td align="center">#orderdata.ordered#</td>
<td align="center">#orderdata.shipqty#</td>
</tr>
</cfoutput>
<cfset filenametouse = 'myFile' />
<cfset theDir = GetDirectoryFromPath(GetCurrentTemplatePath()) />
<cfset theFile = theDir & filenametouse & ".xls" />
<cflock name="fileActionSentItems" type="exclusive" timeout="30" throwontimeout="true">
<cfset SpreadsheetObj = spreadsheetNew()>
<cfset fcol = {}>
<cfset fcol.dataformat = "@">
<cfset SpreadsheetAddRow(SpreadsheetObj, "Part Number, Description, Allocated, On Hand, Pending Receipt, Job Count, Qty Needed, Qty Issued, Order Count, Qty Ordered, Qty Shipped")>
<cfset SpreadsheetAddRow(SpreadsheetObj,"NOT SURE HOW TO GET DATA HERE")>
<cfset SpreadsheetFormatColumn(SpreadsheetObj,fcol,11)>
<cfspreadsheet action="write" filename="#theFile#" name="SpreadsheetObj" sheetname="Sheet1" overwrite="true" />
我不确定如何引用来自多个查询的数据来填充单元格。将查询重写为一个查询一直是一个挑战,我正在尝试一条不同的路线,看看是否有另一种我看不到的方式。