【问题标题】:Add image comment to excel cell将图像注释添加到 Excel 单元格
【发布时间】:2014-03-27 14:04:26
【问题描述】:

使用 C# 向 Excel 中的单元格插入图像注释的最佳方法是什么?

我正在使用 Microsoft.Office.Interop.Excel。

到目前为止,我已经完成了

        Microsoft.Office.Interop.Excel.Application excel = new Microsoft.Office.Interop.Excel.Application();

        Microsoft.Office.Interop.Excel.Workbook wb = excel.Workbooks.Open(filename);
        Microsoft.Office.Interop.Excel.Worksheet sheet = wb.Sheets[1];

        var commnetImage = sheet.Shapes.AddPicture(@"d:\download.jpg", Microsoft.Office.Core.MsoTriState.msoTrue, Microsoft.Office.Core.MsoTriState.msoFalse,
            0, 0, 100, 200);

        var gg = sheet.Cells.Range["E5"];
        gg.ClearComments();
        gg.AddComment(commnetImage);
        wb.Save();

        excel.Quit();

【问题讨论】:

  • 您是否查看过 the Epplus library 以寻找使用 Interops 的替代方案?互操作通常非常缓慢且不可信。我建议在继续您的项目之前先看一下。这是一个非常简单易用的库。几年前,我已经编写了一些示例代码来开始查看。看看My blog
  • 现在才看,看到add comment to cell的例子,支持图片吗??

标签: c# excel-2010 office-interop excel-interop


【解决方案1】:

谢谢大家, 在

找到解决方案

Any open source / free library for handling Excel (both *.xls and *.xlsx) files?

昨天没找到,正在使用这个很棒的开源项目http://spreadsheetlight.com/

【讨论】:

    猜你喜欢
    • 2019-01-02
    • 2011-11-01
    • 2019-03-24
    • 1970-01-01
    • 2014-07-11
    • 2011-08-17
    • 2015-11-09
    • 1970-01-01
    • 2020-01-29
    相关资源
    最近更新 更多