code to add a picture to Excel Comment 

1Insert a picture into a Excel file   Range range = oWorkSheet.get_Range("A1",missing);
2Insert a picture into a Excel file   Excel.Comment comment = range.AddComment("");
3Insert a picture into a Excel file   comment.Shape.Fill.UserPicture("c:\\web.jpg"); 

insert a picture to a Excel file and Save it

1Insert a picture into a Excel file            System.Drawing.Image oImage = System.Drawing.Image.FromFile("c:\\web.jpg");
2Insert a picture into a Excel file            Clipboard.SetDataObject(oImage);
3Insert a picture into a Excel file            Range ImageRange = oWorkSheet.get_Range("A10",missing);
4Insert a picture into a Excel file            oWorkSheet.Paste(ImageRange,"c:\\web,jpg");

Comment: It only be used in the windows form application. If in the web application ,it occours a error like this:

The current thread must set to Single Thread Apartment (STA) mode before
OLE calls can be made. Ensure that your Main function has STAThreadAttribute
marked on it

who can tell me why and how to slove that problem?

相关文章:

  • 2021-06-04
  • 2021-11-28
  • 2021-05-27
  • 2022-01-27
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-10-23
猜你喜欢
  • 2021-09-01
  • 2022-12-23
  • 2022-12-23
  • 2022-02-09
  • 2021-07-22
  • 2021-07-23
  • 2022-12-23
相关资源
相似解决方案