List of usage examples for org.apache.poi.xssf.usermodel XSSFClientAnchor XSSFClientAnchor
public XSSFClientAnchor()
From source file:com.netsteadfast.greenstep.util.SimpleUtils.java
License:Apache License
public static void setCellPicture(XSSFWorkbook wb, XSSFSheet sh, byte[] iconBytes, int row, int col) throws Exception { int myPictureId = wb.addPicture(iconBytes, XSSFWorkbook.PICTURE_TYPE_PNG); XSSFDrawing drawing = sh.createDrawingPatriarch(); XSSFClientAnchor myAnchor = new XSSFClientAnchor(); myAnchor.setCol1(col);/*w ww . ja v a 2 s .c om*/ myAnchor.setRow1(row); XSSFPicture myPicture = drawing.createPicture(myAnchor, myPictureId); myPicture.resize(); }
From source file:org.cgiar.ccafs.ap.summaries.projects.xlsx.BaseXLS.java
License:Open Source License
/** * @throws IOException/*from ww w .j av a2s.co m*/ */ public void createLogo(Workbook workbook, Sheet sheet) throws IOException { // FileInputStream obtains input bytes from the image file InputStream inputStream = new FileInputStream( new File(config.getResourcePath(), "templates" + File.separator + "logo-ccafs.png")); // Get the contents of an InputStream as a byte[]. byte[] bytes = IOUtils.toByteArray(inputStream); // Adds a picture to the workbook int pictureIdx = workbook.addPicture(bytes, Workbook.PICTURE_TYPE_PNG); // close the input stream inputStream.close(); // Creates the top-level drawing patriarch. XSSFDrawing drawing = (XSSFDrawing) sheet.createDrawingPatriarch(); // Set top-left corner for the image XSSFClientAnchor anchor = new XSSFClientAnchor(); anchor.setAnchorType(2); anchor.setCol1(LOGO_POSITION_COLUMN); anchor.setRow1(LOGO_POSITION_ROW); // Creates a picture XSSFPicture pict = drawing.createPicture(anchor, pictureIdx); // Reset the image to the original size pict.resize(); }
From source file:org.wise.vle.web.VLEGetXLS.java
License:Open Source License
/** * Set the comment for a cell/*from w w w .ja va2 s . co m*/ * @param sheet the excel sheet * @param row the excel row * @param column the column index * @param comment the comment string */ private void setCellComment(XSSFSheet sheet, Row row, int column, String comment) { if (row != null) { //get the cell Cell cell = row.getCell(column); if (cell != null) { if (sheet != null) { //make the comment XSSFComment cellComment = sheet.createDrawingPatriarch() .createCellComment(new XSSFClientAnchor()); cellComment.setString(comment); //add the comment to the cell cell.setCellComment(cellComment); } } } }