1. Determine if the specified cell is a merged cell
/*** Function: Determines whether the specified cell is a merged cell * principle: The merged cell in Excel is actually the first cell, except that the cell adds the rowspan and colspan two properties. * and the height and width of the cell into (for example, rowspan=2,colspan=3) 2 rows, 3 columns of the ruler length, and then the merged cells (except the first cell of the remaining 5 cells) hidden. * @paramWsheet *@paramRow *@paramcolumn *@return */ PrivateInteger ismergedregion (Sheet wsheet,intRowintcolumn) { //getnummergedregions: Get all areas for(inti = 0;i < Wsheet.getnummergedregions (); i++){ //gets the specified merge cell range based on the indexCellrangeaddress range =wsheet.getmergedregion (i); intFirstcolumn =Range.getfirstcolumn (); intLascolumn =Range.getlastcolumn (); intFirstRow =Range.getfirstrow (); intLastRow =Range.getlastrow (); if(Row >= firstrow && row <=lastrow) { if(Column >= firstcolumn && column <=lascolumn) { returni; } } } return-1; }
2. Insert Picture
//get picture byte input streamBytearrayoutputstream data =(Bytearrayoutputstream) tempcell.getdata ();//the top manager of paint, a sheet can only get one (be sure to note this)Drawing Drawingpatriarch =Wsheet.createdrawingpatriarch ();//anchor is used primarily to set the properties of a picture//dx1, Dy1, DX2, Dy2, Col1,row1,col2,row2Hssfclientanchor Hssfclientanchor =NewHssfclientanchor (0, 0, 255, 255, ( Short) Firstcolumn,firstrow, ( Short) lastcolumn,lastrow);//I don't know what that means.Hssfclientanchor.setanchortype (ClientAnchor.AnchorType.byId (3));//add a picture to a worksheet and format the picture intPictureindex =workbook.addpicture (Data.tobytearray (), hssfworkbook.picture_type_jpeg); //add picture Mate picture Properties to paint managerDrawingpatriarch.createpicture (Hssfclientanchor,pictureindex);
3.
La La la
Java--POI--Summary of essays