. NET EXCEL Npoi Pictures

Source: Internet
Author: User

There's nothing to write about today. " . NET writes a picture file to EXCEL using the Npoi component "

First look at the effect:

I added the head, this should not be difficult!

Look at the code again:

 private void Button1_Click (object sender, EventArgs e) {///Picture file full path E:\11\DKSG9869_1.jpg St            Ring Path = TxtPath.Text.Trim (); int rowIndex = 0;//first line int colindex = 1;//second column//create workbook Hssfworkbook Hssfworkbook hssfworkb            Ook = new Hssfworkbook (); Create a worksheet ssss hssfsheet sheet = hssfworkbook on the basis of the workbook Hssfworkbook.            Createsheet ("Ssss"); On the basis of worksheet ssss, create a row row hssfrow row = sheet.            CreateRow (RowIndex); Sets the height of rows row.            Height = 1020; Create cell 0 (also called the first column) Hssfcell cell0 = row on the basis of rows row.            Createcell (0); Sets the default width of the first column of the cell cell0.            Sheet.defaultcolumnwidth = 1000; Sets the default height cell0 for the first column of the cell.            Sheet.defaultrowheight = 1000; Writes the value cell0 to the cell (the first column).                         Setcellvalue ("Npoi"); Create cell 1 (also known as the second column) on the basis of rows row Hssfcell cell1 = row.            Createcell (Colindex);          Set the default width for the second column of a cell  Cell1.            Sheet.defaultcolumnwidth = 1000; Sets the default height cell1 for the second column of the cell.            Sheet.defaultrowheight = 1000; Cell1. Sheet.createdrawingpatriarch (). Createpicture (New Hssfclientanchor (0, 0, 1010, 252, Colindex, RowIndex, Colindex, RowIndex), Hssfworkbook. AddPicture (System.IO.File.ReadAllBytes (path), hssfworkbook.picture_type_jpeg)).            LineStyle = Hssfpicture.linestyle_none;            FileStream file = new FileStream (@ "1.xls", FileMode.Create); Hssfworkbook.            Write (file); File.        Close (); }

  

Needless to say, in this sentence.

Cell1. Sheet.createdrawingpatriarch (). Createpicture (New Hssfclientanchor (0, 0, 1010, 252, Colindex, RowIndex, Colindex, RowIndex), Hssfworkbook. AddPicture (System.IO.File.ReadAllBytes (path), hssfworkbook.picture_type_jpeg)). LineStyle = Hssfpicture.linestyle_none;

  

. NET EXCEL Npoi Pictures

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.