Some Useful code for Excel comment

 1Excel.Range  range =  oWorkSheet.get_Range("A1",missing);
 2        
 3            Excel.Comment comment = range.AddComment("");
 4
 5            comment.Shape.Fill.UserPicture(@"d:\\stop.jpg");                                                      //insert the picture 
 6            comment.Shape.Shadow.Visible = Microsoft.Office.Core.MsoTriState.msoFalse;  //set the shadow don't display
 7            comment.Shape.ThreeD.Visible = Microsoft.Office.Core.MsoTriState.msoFalse;   //set the ThreeD effect don't display
 8            comment.Shape.Line.Visible =  Microsoft.Office.Core.MsoTriState.msoFalse;       //set the line hidden
 9            comment.Shape.IncrementLeft((float)-0.75);                                                                  //set the comment shape position
10            comment.Shape.IncrementTop((float)8.25);
11            comment.Text("  ",missing,missing) ;                                                                             //repalce the comment text
12            comment.Visible = true;


Insert a pitcture to excel

1pics.Insert(page.Server.MapPath("../../Images/stop.bmp"),Type.Missing);
2            Excel.Range range =  oWorkSheet.get_Range("D"+EndIndex,"D"+EndIndex);
3            Excel.Picture pics01 = (Excel.Picture)pics.Item(1);
4            pics01.Top = (double)range.Top;
5            pics01.Left = (double)range.Left;
6            pics01.ShapeRange.PictureFormat.TransparentBackground = Microsoft.Office.Core.MsoTriState.msoTrue;
7            pics01.ShapeRange.PictureFormat.TransparencyColor = 0;
8            pics01.ShapeRange.Fill.Visible = Microsoft.Office.Core.MsoTriState.msoFalse;

From:  http://www.codeproject.com/office/office_automation.asp?df=100&forumid=356843&exp=0&select=1815109

posted on 2007-04-11 12:34  广思  阅读(1608)  评论(2)    收藏  举报

导航