C # how to insert a photo to Excel

Source: Internet
Author: User

In the Microsoft news group, I saw a post from jizira asking how to put users' photos in Excel.
I thought it should be very simple, so I first recorded a macro and the result is:
ActiveSheet. Pictures. Insert ("D: t.bmp"). Select

However, in C #, the WorkSheet class does not directly support methods such as Pictures. Insert. In MSDN
On the website, several Office development documents introduce common Application, WorkBook, and Sheet
Like how to read and write. Finally, after reading the help of VBA, we found the solution, which is still very simple:

Excel. Worksheet xSheet = (Excel. Worksheet) xBook. Sheets [1];
XSheet. Shapes. AddPicture ("D: \ tt.bmp", MsoTriState. msoFalse,
MsoTriState. msoTrue, 10, 150,150 );


You can. The second and third parameters indicate whether to link to the file and whether to save the image in the file.
Information (or only save the link information ).

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.