Java--POI--Summary of essays

Source: Internet
Author: User

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

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.