CFSpreadsheet 中的参考 QoQ

发布于 2025-01-04 03:31:58 字数 2192 浏览 2 评论 0原文

我继承了一个页面,该页面从四个表构建库存查询并按 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

痴者 2025-01-11 03:31:58

这个怎么样:

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

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

     <!--- add all columns to an array --->
     <cfset aColumns = [ partdescription, receiptdata.recqty, jobdata.JobCount ] />

     <cfset SpreadsheetAddRow(SpreadsheetObj, ArrayToList(aColumns)) />
</cfoutput>

<cfspreadsheet action="write" filename="#theFile#" name="SpreadsheetObj" sheetname="Sheet1" overwrite="true" />

How about this:

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

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

     <!--- add all columns to an array --->
     <cfset aColumns = [ partdescription, receiptdata.recqty, jobdata.JobCount ] />

     <cfset SpreadsheetAddRow(SpreadsheetObj, ArrayToList(aColumns)) />
</cfoutput>

<cfspreadsheet action="write" filename="#theFile#" name="SpreadsheetObj" sheetname="Sheet1" overwrite="true" />
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文