Show / Hide Table of Contents

Add Comments with picture background (fill)

Output: CommentsPictureFill.xlsx

public void Run()
{
    var workbook = new Workbook();
    var worksheet = workbook.Worksheets[0];

    worksheet.GetRange("A1:A10").SetRowsHeight(60);
    worksheet.Columns["A"].WidthPixels = 100;
    worksheet.Columns["B"].WidthPixels = 100;
    
    worksheet["A2"].AddComment("DR-IT", "Comment");
    this.FormatComment(worksheet, "A2");
    worksheet["A2"].Comment.SetImage("smiley.png");
    
    workbook.SaveAs("CommentsPictureFill.xlsx");
}

private void FormatComment(Worksheet worksheet,string label)
{
    worksheet[label].Comment.Size.WidthPixels = 80;
    worksheet[label].Comment.Size.HeightPixels = 50;
    //Anchor the comment shape one row above and one column to the left
    worksheet[label].Comment.AnchoredCell = worksheet[worksheet[label].Row.Index - 1, worksheet[label].Column.Index + 1];
    //Always show the comment
    worksheet[label].Comment.Visible = true;
}
Back to top Generated by DocFX