cfspreadhseet - 如何删除/更新单元格中的评论?

问题描述 投票:0回答:1

我正在使用 cfspreadsheet 来更新 xl 文件的内容,也有兴趣为用户添加注释,以便他获得单元格的更多信息。

当我尝试向具有现有评论的特定单元格添加评论时,出现以下错误,因此在文档中的这种情况下,我没有看到删除现有评论或更新现有评论或清除整个单元格使用数据和评论....不知道如何管理单元格中的评论...(我通过根据下面得到的回复添加锚标记来修复错误,但现在当我下载相同的文件时,我没有能够看到被覆盖的注释,并且收到损坏数据的 xl 异常)

CF 文档为我们提供了一个用于注释的获取和设置函数(SpreadsheetSetCellComment 和 SpreadsheetGetCellComment)....并且 set 函数也没有覆盖属性...

有什么想法吗??

未添加锚标记的初始错误: 错误:java.lang.IllegalArgumentException:一个单元格中不允许有多个单元格注释,

打开 xl 文件时出错(覆盖注释后) 当我们尝试覆盖现有评论时,打开文件时从 xl 收到以下错误。

记录: error357560_01.xml在文件“C:\Users\username\Downloads\dtStatistics_870.xls”中检测到错误已删除的记录:/xl/comments1.xml 部分的评论(评论)

java coldfusion coldfusion-9 coldfusion-10 cfml
1个回答
0
投票

尝试使用包含评论的单元格的行号和列号来指定评论

anchor
(评论框的位置):

<cfscript>
path = ExpandPath( "test.xlsx" );
workbook = SpreadsheetNew( "sheet1", true ); //xlsx
// this is where are cell lives
row = 1;
column = 1;
// use these values to position the comments box
anchor = [ row, column, row+2, column+2 ];
// create the cell
SpreadsheetSetCellValue( workbook, "test", row, column );
// create the initial comment
comment = {
    author: "cfsimplicity"
    ,comment: "a comment"
    ,anchor: anchor.ToList()
};
SpreadsheetSetCellComment( workbook, comment, row, column );
WriteDump( SpreadsheetGetCellComment( workbook, row, column ) );
//Now update the comment
comment.comment = "an updated comment";
SpreadsheetSetCellComment( workbook, comment, row, column );
WriteDump( SpreadsheetGetCellComment( workbook, row, column ) );
SpreadsheetWrite( workbook, path, true );
</cfscript>

这应该可以防止使用临时值或默认值,我认为这可能会导致此问题。

© www.soinside.com 2019 - 2024. All rights reserved.