我正在学习ColdFusion,我正在尝试使用spreadsheetFormatRows(spreadsheetObject、dataFormat、rangeOfRowsFormated)处理电子表格。
如何将范围设置为包括除标题行之外的所有行,该行用于列名?是否有一个函数返回cfspreadsheet对象上的行数,以便我可以将范围设置为“2-rowCount”?
我尝试了spreadsheetFormatRows(theSheet, headerFormat, 2-50);,工作良好,格式化了第2行到第50行,但我不想使用硬编码。
提前谢谢你。
发布于 2017-03-22 13:05:27
电子表格对象具有属性行计数。你可以做spreadsheetFormatRows(theSheet, format, "2-#theSheet.rowCount#");
<cfscript>
mySheet = spreadSheetNew("My Sheet");
spreadSheetAddRow(mySheet, "'Col. A','Col. B','Col. C'");
for(i=1; i <= RandRange(1, 100); i++){
spreadSheetAddRow(mySheet, "'Row A#i#','Row B#i#','Row C#i#'");
}
spreadSheetFormatRow(mySheet, {bold = true, fontsize = 24}, 1);
spreadSheetFormatRows(mySheet, {fontsize = 16}, "2-#mySheet.rowcount#");
cfheader(name = "Content-Disposition", value = 'inline; fileName="test.xls"');
cfcontent(type="application/vnd.ms-excel", variable="#spreadSheetReadBinary(mySheet)#");
</cfscript>试着上网
发布于 2017-03-22 03:00:24
在填充行时跟踪行数,并将值保存到变量中。如果它们是查询结果,则使用cfquery中的记录计数变量。
请记住添加1,以便格式化最后一行。
https://stackoverflow.com/questions/42937452
复制相似问题