如何在ColdFusion中replace.xlsx文件中的逗号?

我有excel文件,可以在一些字段中包含逗号。 这可能会导致问题,如果我想使用cfspreadsheet将我的文件转换为csv 。 我想知道是否有方法来replaceconvert所有的逗号\ 。 在我replace所有逗号后,我将能够使用cfspreadsheet创buildcsv 。 这里是我的代码如何阅读我的文件:

 <cfspreadsheet action = "read" format="csv" src="filePath\myFile.xlsx" name="csvvar"> 

如果有人可以帮助解决这个问题,请让我知道。 谢谢。

从Excel转换为查询。 然后,在每行的单元格数据中,将“,”replace为“\”。 像这样的东西

 <cfspreadsheet action = "read" src="filePath\myFile.xlsx" query="excelquery" sheet="1"> <!--- Create CSV file in current directory---> <cffile action="write" file="#expandpath('result.csv')#" output=""> <cfset columns = arraynew(1)> <!--- Store the list of column names as an array ---> <cfset columns = listToArray(excelquery.ColumnList)> <cfoutput query="excelquery"> <cfset rowList = ""> <cfloop from="1" to="#arraylen(columns)#" index="n"> <cfset colName = columns[n]> <cfset cellData = evaluate("#colName#[currentrow]")> <!--- Replace , by \ in each cell ---> <cfset cellData = replace(cellData, ",", "\", "all")> <!--- Comma-separated row data ---> <cfset rowList = listAppend(rowList,cellData)> </cfloop> <!--- Place a carriage-return at the end of the row ---> <cfset rowList = rowList & '<br>'> <!--- Append row to CSV file ---> <cffile action="append" file="#expandpath('result.csv')#" output="#rowList#" > </cfoutput>