Insert a picture into a Excel file
code to add a picture to Excel Comment
1
Range range = oWorkSheet.get_Range("A1",missing);
2
Excel.Comment comment = range.AddComment("");
3
comment.Shape.Fill.UserPicture("c:\\web.jpg");
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
2
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
3
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
insert a picture to a Excel file and Save it
1
System.Drawing.Image oImage = System.Drawing.Image.FromFile("c:\\web.jpg");
2
Clipboard.SetDataObject(oImage);
3
Range ImageRange = oWorkSheet.get_Range("A10",missing);
4
oWorkSheet.Paste(ImageRange,"c:\\web,jpg");
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
2
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
3
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
4
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
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?