将行添加到coldfusion电子表格的功能是SpreadsheetAddrow将数据接受为"以逗号分隔的单元格条目列表,每列一个".
我的一些数据中包含逗号.如何在不转义列表中的逗号的情况下转义数据中的逗号?
我目前正在创建一个包含该行内容的数组,然后将其转换为列表以添加到电子表格中:
<cfset row = ArrayNew(1)>
<cfloop list="#structKeyList(setRecord.columns)#" index="key">
<cfset ArrayAppend(row, "#Evaluate(key)#")>
</cfloop>
<cfset spreadsheetAddRow(xlsObj, "#ArrayToList(row)#")>
Run Code Online (Sandbox Code Playgroud) 我正在尝试使用 cfspreadsheet 创建一个 excel 文件。在其中一列中,我有 html 代码,但由于某种原因,在 excel 文件中,html 没有被呈现,它只是纯文本。例如。<b>blabla</b>而不是加粗。
你知道有什么解决办法吗?
我想格式化电子表格如下,但找不到使用cfspreadsheet或独立的电子表格()函数执行它的正确功能.
请指教!
我有一张excel表,其中添加有红色背景,更改有黄色背景,删除是灰色.我希望做的是读取工作表,并根据单元格背景颜色执行相关的数据库操作.
通常我会在每个列中创建每种类型的操作,或者添加另一列来确定操作.
我有什么选择来获取电子表格对象中返回的"格式"?
谢谢
我正在创建一个查询,然后将其下载到一个 excel 文档中。我想在 excel 文档中包含一些链接,但不知道该怎么做。我尝试只在querySetCell()值中放置一个锚标记,但这只是在 excel 文件中打印 html,不会解析 html。我正在使用CF10。以下是我的代码,任何建议表示赞赏。
<cfset q = queryNew("#columnNames#")>
<cfset queryAddRow(q)>
<cfset querySetCell(q, "Attributes", "Part Number")>
<cfset querySetCell(q, "PrimaryPart", "#local.primaryPart.getProductNumber()#")>
<cfset i = 0>
<cfloop array="#local.comparableParts#" index="part">
<cfset i++>
<cfset querySetCell(q, "alternatePart"& i, "#part.getPartNumber()#")>
</cfloop>
<cfspreadsheet action="write" query="q" filename="partCompare.xls" overwrite="true" />
<!--- Make a spreadsheet object --->
<cfset s = spreadsheetNew()>
<!--- Add header row --->
<cfset spreadsheetAddRow(s, "#columnNames#")>
<!--- format header --->
<cfset spreadsheetFormatRow(s, {bold=true, fgcolor="lemon_chiffon"}, 1)>
<cfset spreadsheetAddRows(s, q)>
<cfheader name="content-disposition" value="attachment; …Run Code Online (Sandbox Code Playgroud) coldfusion excel export-to-excel coldfusion-10 cfspreadsheet
我们有一个Coldfusion应用程序,它运行一个大型查询(最多100k行),然后以HTML格式显示它.然后,UI提供一个"导出"按钮,使用cfspreadsheet标签和电子表格函数触发将报告写入.xlsx格式的Excel电子表格,特别是用于构建行列值的spreadsheetSetCellValue,以及用于格式化的spreadsheetFormatRow和spreadsheetFormatCell函数.然后使用以下命令将ssObj写入文件:
<cfheader name="Content-Disposition" value="attachment; filename=OES_#sel_rtype#_#Dateformat(now(),"MMM-DD-YYYY")#.xlsx">
<cfcontent type="application/vnd-ms.excel" variable="#ssObj#" reset="true">
Run Code Online (Sandbox Code Playgroud)
其中ssObj是SS对象.我们看到的文件大小约为5-10 Mb.
但是......创建此报告和写入文件的内存使用量会增加大约1GB.复合问题是在java GC导出完成后,内存不会立即释放.当我们有多个用户运行并导出这种类型的报告时,内存不断攀升并达到分配的堆大小,并将服务器的性能降低到服务器关闭的程度.通常需要重新启动才能将其清除.
这是正常/预期的行为还是我们应该如何处理这个问题?导出完成后,是否可以根据需要轻松释放此操作的内存使用情况,以便运行报表的其他人可以轻松访问已释放的报表空间?对于5-10Mb文件,这种类型的内存使用是否与cfspreadsheet函数相同并将对象写出来?
我们已经尝试过暂时删除昂贵的格式化函数,但是对于.xlsx文件的创建和编写,内存使用量仍然很大.我们还尝试使用spreadsheetAddRows方法和cfspreadsheet action ="write"query ="queryname"标记传递查询对象,但这也占用了大量内存.
为什么这些功能如此记忆晦暗?如果没有内存不足问题,生成Excel SS文件的最佳方法是什么?
我应该添加服务器在Windows上的Apache/Tomcat容器中运行,我们正在使用CF2016.
这是我将查询输出到电子表格的代码.
<cfscript>
//Use an absolute path for the files. --->
theDir=GetDirectoryFromPath(GetCurrentTemplatePath());
theFile=theDir & "getTestInv.xls";
//Create an empty ColdFusion spreadsheet object. --->
theSheet = SpreadsheetNew("invoicesData");
//Populate the object with a query. --->
SpreadsheetAddRows(theSheet,getTestInv);
</cfscript>
<cfset format = StructNew()>
<cfset format.dataformat = "#,###0.00">
<cfset SpreadsheetFormatColumn(theSheet,format,10)
<cfspreadsheet action="write" filename="#theFile#" name="theSheet" sheetname="getTestInv" overwrite=true>
Run Code Online (Sandbox Code Playgroud)
我得到的错误是:
Invalid CFML construct found on line 125 at column 32.
ColdFusion was looking at the following text:
,
The CFML compiler was processing:
An expression beginning with /", on line …Run Code Online (Sandbox Code Playgroud) coldfusion dataformat export-to-excel coldfusion-10 cfspreadsheet
我正在使用ColdFusion和SpreadsheetNew,SpreadsheetAddRows,SpreadsheetFormatRows等功能创建Excel文件.根据我在这里阅读的文档,他们是颜色和fgcolor的推荐.我对两者之间的区别有点困惑.一个是文字颜色而另一个是背景颜色?我一直在使用fgcolor来设置行的背景颜色.
// HEADER ROW FORMAT
formatHeaderRow = StructNew();
formatHeaderRow.fgcolor="royal_blue";
Run Code Online (Sandbox Code Playgroud)
我的主要问题是,根据文档,我可以在org.apache.poi.hssf.util.HSSFColor颜色类中提供任何值作为我的颜色.但是,我真的需要提供HEX值或RGB.我知道Excel可以处理它,因为你可以在excel的colorpicker中输入.有没有办法为我的行颜色输入HEX或RGB值?
谢谢!
UPDATE
<cfscript>
// create XLSX workbook with a few cells
// and grab underlying POI objects
cfSheet = Spreadsheetnew("Sheet1", true);
poiWorkbook = cfSheet.getWorkBook();
poiSheet = poiWorkbook.getSheet("Sheet1");
// Create reusuable style objects
// NOTE: Excel limits the maximum number of styles allowed. So do not create a new
// style for every cell. Create distinct styles once, and apply to multiple cells/rows.
Color = createObject("java", "java.awt.Color"); …Run Code Online (Sandbox Code Playgroud) 我正在使用cfspreadsheet生成excel电子表格.我一个接一个地添加行.我添加行后,我想立即格式化它.像这样的东西:
<cfset SpreadsheetAddRow(mySpreadsheet, "hi,this,is,a,test") />
<cfset SpreadsheetFormatRow(mySpreadsheet,
{
fgcolor:red;
}) />
Run Code Online (Sandbox Code Playgroud)
但是,对于formatrow函数,您必须提供行号.有没有办法格式化我刚刚添加的行而不保持我正在运行的行的运行计数器?
我正在从电子表格中读取数据.电子表格中的一列包含空格.
例如,列名称是[名字,姓氏,名称].
我正在qryObj阅读电子表格.现在,当我尝试从查询中读取名字时
<cfquery dbtype="query" name="getName">
SELECT [first name]
FROM qryObj
</cfquery>
Run Code Online (Sandbox Code Playgroud)
它正在抛出db错误.我也尝试了['first name']但仍然是抛出错误.
错误是:
Query Of Queries syntax error.
Encountered "[. Incorrect Select List, Incorrect select column
Run Code Online (Sandbox Code Playgroud) 'excelFileQuery'包含一个查询.
<cfset spreadsheetAddRows(s, excelFileQuery)>
<cfset spreadsheetAddRows(s,"#volunteeralias# Export Report (#dateformat(now(),'mmmm d, yyyy')# at #timeformat(now(),'h:mm tt')#)",1,1)>
<cfheader name="content-disposition" value="attachment; filename=myexcel.xlsx">
<cfcontent type="application/msexcel" variable="#spreadsheetReadBinary(s)#" reset="true">
Run Code Online (Sandbox Code Playgroud)
但是当生成文件时,查询行会显示,而不是第二行.我做错了吗?
我正在尝试使用 Coldfusion 构建 Excel xlsx 工作簿。我使用各种电子表格XYZ 函数来执行此操作。我遇到的一个问题是,我正在运行的一些导出有大量数据,因此内存似乎成为问题。我的理解是,coldfusion 电子表格函数将所有内容保留在内存中,直到调用 SpreadsheetWrite 为止。
是否有更有效的方法来生成具有多个工作表和大量数据的工作簿?
cfspreadsheet ×12
coldfusion ×12
excel ×4
spreadsheet ×2
cfquery ×1
coldfusion-9 ×1
colors ×1
comma ×1
dataformat ×1
export ×1
format ×1
html ×1
list ×1
margin ×1
orientation ×1
performance ×1
xlsx ×1