ColdFusion (9) 在导出到 Microsoft Excel (2007) 时神秘地删除了数字后的字符“D"和“F" [英] ColdFusion (9) mysteriously removes characters 'D' and 'F' after numbers when exporting to Microsoft Excel (2007)
问题描述
以下是一些示例代码片段:
Here's some code snippets for an example:
theSheet = SpreadsheetNew("Rates","True");
SpreadsheetAddRow(theSheet,"4A,4B,4C,4D,4E,4F,4G,4H,4I,4J");
SpreadsheetAddRow(theSheet,"4K,4L,4M,4N,4O,4P,4Q,4R,4S,4T");
SpreadsheetAddRow(theSheet,"4U,4V,4W,4X,4Y,4Z,4D4,4F4");
和
<cfheader name="content-disposition" value="attachment; filename=#GetTickCount()#.xlsx">
<CFHEADER NAME="Expires" VALUE="#now()#">
<cfcontent type="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet" variable="#SpreadsheetReadBinary(theSheet)#"/>
问题是4D"和4F"(而不是其他)丢失了D"和F"并被格式化为数字.
The issue is that "4D" and "4F" (and not the others) lose the 'D' and 'F' and are formatted as a number.
我试过了:
formatText = StructNew();
formatText.dataformat="@";
SpreadsheetFormatColumns(theSheet,formatText,"1-10");
我确认这将 Excel 中的格式设置为文本",但现在我只在文本格式的单元格中看到数字 4!我也尝试使用 ' 字符,但是当它在 Excel 中打开时,它只显示 ' 而不是文字化单元格.
I verified that this set the format in Excel to "Text", but now I just see the number 4 in a Text-formatted cell! I also tried using the ' character, but when it opens in Excel, it just shows the ' instead of literalizing the cell.
这很奇怪;有人知道发生了什么吗?
This is rather strange; anybody have an idea about what's going?
推荐答案
似乎解决方法是将单元格公式设置为文字4D".
It seems that a workaround is to set the cell formula to be the literal "4D".
theSheet = SpreadsheetNew("Rates","True");
SpreadsheetAddRow(theSheet,"4A,4B,4C,,4E,,4G,4H,4I,4J");
SpreadsheetSetCellFormula(theSheet, """4D""", 1, 4);
SpreadsheetSetCellFormula(theSheet, """4F""", 1, 6);
SpreadsheetAddRow(theSheet,"4K,4L,4M,4N,4O,4P,4Q,4R,4S,4T");
SpreadsheetAddRow(theSheet,"4U,4V,4W,4X,4Y,4Z,4D4,4F4");
我仍然不知道为什么会发生这种情况,但我的想法是 SpreadsheetAddRow() 和 SpreadsheetSetCell() 将 4D 和 4F 解释为数字,并将 D 和 F 以及后缀解释对于 Double 和 Float,并在转换后将它们剥离.
I still don't know why this is happening, but my idea is that SpreadsheetAddRow() and SpreadsheetSetCell() are interpreting 4D and 4F as numeric and are interpreting the D and F and suffixes standing for Double and Float, and stripping them out after conversion.
您可以转到 https://bugbase.adobe.com/index.cfm 将错误提交给 Adobe.
You can submit the bug to Adobe by going to https://bugbase.adobe.com/index.cfm.
这篇关于ColdFusion (9) 在导出到 Microsoft Excel (2007) 时神秘地删除了数字后的字符“D"和“F"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!