ColdFusion (9) 神秘地删除了字符“D”和“F”导出到 Microsoft Excel 时在数字之后 (2007)

发布于 2024-10-24 08:56:44 字数 906 浏览 4 评论 0原文

以下是示例的一些代码片段:

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”并被格式化为数字。

我尝试了这个:

formatText = StructNew();
formatText.dataformat="@";
SpreadsheetFormatColumns(theSheet,formatText,"1-10");

我验证了这将 Excel 中的格式设置为“文本”,但现在我只在文本格式的单元格中看到数字 4!我还尝试使用 ' 字符,但是当它在 Excel 中打开时,它只显示 ' 而不是字面化单元格。

这很奇怪;有人知道发生了什么吗?

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");

and

<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)#"/>

The issue is that "4D" and "4F" (and not the others) lose the 'D' and 'F' and are formatted as a number.

I tried this:

formatText = StructNew();
formatText.dataformat="@";
SpreadsheetFormatColumns(theSheet,formatText,"1-10");

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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

疧_╮線 2024-10-31 08:56:44

似乎解决方法是将单元格公式设置为文字“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 和 的后缀解释为浮动,并在转换后将它们剥离。

您可以转至 https://bugbase.adobe.com/index.cfm 将错误提交给 Adob​​e。

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");

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.

You can submit the bug to Adobe by going to https://bugbase.adobe.com/index.cfm.

半世蒼涼 2024-10-31 08:56:44

您应该尝试显式使用 D 字符代码 chr(68) 而不是“D”。

You should try to use D char code explicitly chr(68) instead of "D".

依 靠 2024-10-31 08:56:44

您可以尝试旧的电子表格技巧 - 回到 Lotus 时代 - 通过以单引号开始条目来将值强制转换为文本:'4D

You might try the old spreadsheet trick -- going back to Lotus days -- of coercing values to text by starting the entry with a single quote: '4D.

吐个泡泡 2024-10-31 08:56:44

我更新了相关堆栈问题中的代码以搜索字符(通过前置或附加到给定文本来使用)以隐藏此 ColdFusion 功能:

WorkBook = spreadsheetNew('Test', true);
RowNumber = 1;  
for (i = 1; i <= 255; i++){
    SpreadSheetSetCellValue(WorkBook, i, RowNumber, 1);

    // what character are we displaying
    SpreadSheetSetCellValue(WorkBook, chr(i), RowNumber, 2);

    // see if appending chr(i) allows 4F to display
    SpreadSheetSetCellValue(WorkBook, "4F#chr(i)#", RowNumber, 3);

    // see if appending chr(i) allows 4F to display
    SpreadSheetSetCellValue(WorkBook, "#chr(i)#4F", RowNumber, 4);
    RowNumber ++;
}

原来前置或附加不可打印字符 chr(127) 和 chr(160) 维护了 我提到的4F 或 4D

相关堆栈问题: cfspreadsheet 字母数字值以 d 结尾

I updated code from a related stack question to search for characters (to use by prepending or appending to the given text) to hide this ColdFusion feature:

WorkBook = spreadsheetNew('Test', true);
RowNumber = 1;  
for (i = 1; i <= 255; i++){
    SpreadSheetSetCellValue(WorkBook, i, RowNumber, 1);

    // what character are we displaying
    SpreadSheetSetCellValue(WorkBook, chr(i), RowNumber, 2);

    // see if appending chr(i) allows 4F to display
    SpreadSheetSetCellValue(WorkBook, "4F#chr(i)#", RowNumber, 3);

    // see if appending chr(i) allows 4F to display
    SpreadSheetSetCellValue(WorkBook, "#chr(i)#4F", RowNumber, 4);
    RowNumber ++;
}

Turns out prepending or appending nonprintable characters chr(127) and chr(160) maintain the presentation of 4F or 4D

Related stack question I mentioned: cfspreadsheet alphanumeric values ending in d

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文