CFSpreadsheet 中的参考 QoQ
我继承了一个页面,该页面从四个表构建库存查询并按 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" />
我不确定如何引用数据来填充单元格,因为它来自多个查询。将查询重写为一个查询一直是一项挑战,我正在尝试一种不同的路线,看看是否还有另一种我没有看到的方法。
I've inherited a page that builds an inventory query from four table and outputs them with a 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" />
I am not certain how to reference the data to populate the cells as it comes from multiple queries. Rewriting the query into one has been a challenge and I'm trying a different route to see if there is another way I don't see.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这个怎么样:
How about this: