对受保护的工作表列的评论

时间:2017-11-07 11:54:25

标签: c# xlsx epplus worksheet openoffice-calc

我正在尝试将数据导出到Excel。导出工作正常,我希望保护我的前两列,以便用户只能编辑第三列。那工作得很好。

但是,我向单元格添加注释,并且不显示受保护的单元格中的注释。

我的Google-Fu躲过了我,我找不到任何关于这个主题的内容。我不是一个Excel专家,但最重要的是我只有OpenOffice进行测试。所以我真的不知道我想要的是否可能。也许这是正常的Excel行为或正常的OpenOffice行为?

for (int index = 0; index < lines.Length; index++)
{
    worksheet.Cells[index + 2, 1].Value = lines[index].Name;
    worksheet.Cells[index + 2, 2].Value = lines[index].DataSource;
    worksheet.Cells[index + 2, 3].Value = lines[index].DataDestination;

    worksheet.Comments.Add(worksheet.Cells[index + 2, 1], "my comment", "XXX");
}

using (var autoFitRange = worksheet.Cells["A1:C" + (lines.Length + 1)])
{
    autoFitRange.AutoFitColumns();
}

worksheet.Protection.AllowInsertRows = false;
worksheet.Protection.AllowSort = true;
worksheet.Protection.AllowSelectUnlockedCells = true;
worksheet.Protection.AllowAutoFilter = true;
worksheet.Protection.AllowFormatCells = true;
worksheet.Protection.AllowSelectLockedCells = true;

worksheet.Protection.IsProtected = true;

// if I unlock the column, the comment will be available
//     worksheet.Column(1).Style.Locked = false;

worksheet.Column(3).Style.Locked = false;

那么如何在锁定列上提供评论?或者那是不可能的?

0 个答案:

没有答案
相关问题