TVO*_*OHM 4 c# excel excel-interop
我可以使用Range.AddComment方法以编程方式在C#中向Excel单元格添加注释:
range.Cells[1, 1].AddComment("Hello World!");
Run Code Online (Sandbox Code Playgroud)
我的问题是我需要添加的一些评论很长.在我的测试过程中,无论评论有多长,评论框似乎都保持默认大小.这意味着用户在最初单击单元格时无法看到所有注释.
有没有一种方法可以用来更好地控制注释的显示方式,这样我可以避免这个问题?
试试这个:
Range cell = (Range)sheet.Cells[1, 1];
Comment comment = cell.AddComment("blah");
comment.Shape.TextFrame.AutoSize = true;
Run Code Online (Sandbox Code Playgroud)
编辑:更长的文字和不同的方法:
string text = "Lorem ipsum dolor sit amet, consectetur adipiscing elit,\n sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.\n"+
"Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris\n nisi ut aliquip ex ea commodo consequat."+
"Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.\n"+
"Excepteur sint occaecat cupidatat non proident, sunt in \nculpa qui officia deserunt mollit anim id est laborum";
Range cell = (Range)sheet.Cells[1, 1];
Comment comment = cell.AddComment();
comment.Shape.TextFrame.AutoSize = true;
comment.Text(text);
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1496 次 |
| 最近记录: |