我想以十六进制代码将单元格的前景色设置为给定的颜色.例如,当我尝试将其设置为红色时:
style.setFillForegroundColor(new XSSFColor(Color.decode("#FF0000")).getIndexed());
Run Code Online (Sandbox Code Playgroud)
无论我在解码函数的参数中设置了什么十六进制值,getIndexed函数将始终返回黑色.
难道我可能做错了吗?我认为这是一个错误,但我不确定......
最近从CF11升级到CF2021。我有一个电子表格,我们用颜色来格式化单元格、行和列,特别是背景颜色。我指定了 color= 或 fgcolor=。无论我选择什么颜色,它都会是黑色的。我搜索并搜索了 2021 年,但一无所获。
有人有解决方案吗?
非常简化的代码。它适用于 CF11 和 CF2016。
<cfscript>
sObj = SpreadsheetNew("Testing Summary","yes");
SpreadsheetSetCellValue(sObj,"As of: " & DateFormat(#DateAdd("h", -1, Now())#),1,1);
SpreadsheetFormatCell(sObj, {bold="true", fontsize="14"}, 1,1);
SpreadsheetMergeCells(sObj,1,1,1,5);
SpreadsheetSetCellValue(sObj,"Testing Summary",2,1);
SpreadsheetMergeCells(sObj,2,2,1,5);
SpreadsheetFormatCell(sObj, {bold="true", fontsize="20", fgcolor="blue", color="yellow"}, 2,1);
</cfscript>
<!--- Launch File to User --->
<cfheader name="Content-Disposition" value="attachment; filename=MySpreadsheet.xlsx">
<cfcontent type="application/vnd.ms-excel" variable="#SpreadsheetReadBinary( sObj )#">
Run Code Online (Sandbox Code Playgroud)