Home > Net >  .net npoi inserted into the cell, not to follow the cell images
.net npoi inserted into the cell, not to follow the cell images

Time:03-25

Asp.net using npoi open the excel template, dynamic inserting data into line 19, template line 22 put pictures, how can I when inserting data pictures follow cell

CodePudding user response:

Specify the anchor order cell try:
 
Int pictureIdx=workbook. AddPicture (bytes, PictureType. JPEG);
HSSFPatriarch patriarch=(HSSFPatriarch) sheet1. CreateDrawingPatriarch ();
//the location of the photograph HSSFClientAnchor (dx1, dy1, dx2, dy2, col1, row1, col2, row2)
HSSFClientAnchor anchor=new HSSFClientAnchor (70, 10, 0, 1, rowline, 2, rowline + 1);
//the images into the corresponding location
HSSFPicture Pict=(HSSFPicture) patriarch. CreatePicture (anchor, pictureIdx);

If the image is already in the template, is set in the Excel,
If is dynamically add, you can add a picture, in the final data is populated before you sure you want to put the picture in which line

CodePudding user response:

Picture is the inside of the template, excel there are set up with the position of the cell, insert the copy line with sheet. ShiftRows (start, sheet. LastRowNum + 1, dtaaa Rows. The Count - 1, true, false) method

CodePudding user response:

Tried it on, do have a problem, pictures not automatically as cell move,

Maybe in the generated after insert some pictures to the designated location better operation

CodePudding user response:

It is better to use dynamic, feel good, just read a picture data flow, no problem with above big code,
  • Related