【问题标题】:C# Excel Interop: Set multiple cell COMMENTS at onceC# Excel 互操作:一次设置多个单元格注释
【发布时间】:2016-07-26 07:07:53
【问题描述】:

我最近想出了如何在一个范围内写入单元格值:

Excel.Range rng = (Excel.Range)xlWorkSheet.Range[xlWorkSheet.Cells[1, 1], xlWorkSheet.Cells[10, 10]];
rng.Value = new string[,] { ... };

这极大地加快了我的应用程序的速度,但我也希望能够设置整个范围的单元格 cmets!我只发现了对一系列单元格发表评论的可能性。一条评论。但它似乎并不存在于 api 中。

【问题讨论】:

    标签: c# excel


    【解决方案1】:

    您不能一次设置多个单元格评论,但您可以从一个单元格复制评论并将其粘贴到多个单元格:

    var a1 = xlWorkSheet.Range("A1")
    a1.ClearComments(); // just in case 
    a1.AddComment("some comment");
    a1.Copy();
    a1.Resize(10, 10).PasteSpecial(Excel.XlPasteType.xlPasteComments);
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-01-15
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多