When adding data to an array, one of the elements has commas in its value. An example of the value is "Trim marks at 103, 96, and 90".
Using the following code to add the array elements to the spreadsheet object, the partdescription element, as described above, has its data span multiple columns in the spreadsheet. It is handled as separate elements and not one.
<!---Create file name variable--->
<cfset filenametouse = 'PartLevel_Report' />
<!---Set directory and full file path--->
<cfset theDir = GetDirectoryFromPath(GetCurrentTemplatePath()) />
<!---Attach file extension to full file path and file name--->
<cfset theFile = theDir & filenametouse & ".xls" />
<cflock name="fileActionSentItems" type="exclusive" timeout="30" throwontimeout="true">
<cfset SpreadsheetObj = spreadsheetNew()>
<cfset fcol = {}>
<cfset fcol.dataformat = "@">
<!---Create the column headings--->
<cfset SpreadsheetAddRow(SpreadsheetObj, "Part ##, Reorder ##, Description, Bin ##, Current Inv., Staged, Allocations, Available Inv., Shelf Count, Total Shipped, Total ## of Stores, Total Ordered, Avg. Per Store, Lead Time (in days), Low Water Mark, Total ## of Stores Remaining")>
<cfoutput query="getParts" group="partnum">
<cfset aColumns = [ partnum , shortchar08 , partdescription , binlist , inventory.currinv , staged.stagedqty , alloc.allocqty , available , shelfCount , shipdtl.shipqty , getNumberofStores.numStores , tordered , APS, paddedLeadTime, LWM , storesRemain] />
<!---add the column data to the spreadsheet--->
<cfset SpreadsheetAddRow(SpreadsheetObj, ArrayToList(aColumns)) />
</cfoutput>
<!---Generate the spreadsheet--->
<cfspreadsheet action="write" filename="#theFile#" name="SpreadsheetObj" sheetname="Sheet1" overwrite="true" />
How may I alleviate this issue?
Solved: I set a variable to the partdescription with all commas replaced with semicolons. Now the data appears all in the same column:
<cfset cleanDesc = rereplace(partdescription, ",", ";", "all")>
<cfset aColumns = [ partnum , shortchar08 , cleanDesc , binlist , inventory.currinv , staged.stagedqty , alloc.allocqty , available , shelfCount , shipdtl.shipqty , getNumberofStores.numStores , tordered , APS, paddedLeadTime, LWM , storesRemain] />