0

4 つのテーブルから在庫クエリを作成し、それらを 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" />

データは複数のクエリから取得されるため、データを参照してセルにデータを入力する方法がわかりません。クエリを 1 つに書き直すことは困難であり、別のルートを試して、表示されていない別の方法があるかどうかを確認しています。

4

1 に答える 1

0

これはどう:

<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" />
于 2012-02-08T21:59:01.643 に答える