Java 类org.apache.poi.ss.usermodel.ClientAnchor 实例源码

项目:Gargoyle    文件:FxExcelUtil.java   
/**
 * @작성자 : KYJ
 * @작성일 : 2016. 9. 9. 
 * @param sheet
 * @throws Exception
 */
final static void createDefaultLogo(Sheet sheet) throws Exception {
    Workbook workbook = sheet.getWorkbook();
    byte[] defaultLogoImage = getDefaultLogoImage();
    if(defaultLogoImage == null)
        return;
    int pictureIdx = workbook.addPicture(defaultLogoImage, Workbook.PICTURE_TYPE_PNG);

    CreationHelper creationHelper = workbook.getCreationHelper();
    ClientAnchor anchor = creationHelper.createClientAnchor(); //new XSSFClientAnchor();
    //          anchor.setAnchorType(AnchorType.MOVE_DONT_RESIZE);
    Drawing createDrawingPatriarch = sheet.createDrawingPatriarch();
    anchor.setDx1(0);
    anchor.setCol1(0);
    anchor.setRow1(0);

    //#1 테이블 셀의 너비에 의존적이지않게 사이즈조절.
    anchor.setAnchorType(AnchorType.MOVE_DONT_RESIZE);
    Picture createPicture = createDrawingPatriarch.createPicture(anchor, pictureIdx);
    //#2 테이블 셀의 너비에 의존적이지않게 사이즈조절.
    createPicture.resize();
}
项目:turnus    文件:PoiUtils.java   
/**
 * See the comment for the given cell
 * 
 * @param cell
 *            the cell
 * @param message
 *            the comment message
 */
public static void setComment(HSSFCell cell, String message) {
    Drawing drawing = cell.getSheet().createDrawingPatriarch();
    CreationHelper factory = cell.getSheet().getWorkbook().getCreationHelper();

    // When the comment box is visible, have it show in a 1x3 space
    ClientAnchor anchor = factory.createClientAnchor();
    anchor.setCol1(cell.getColumnIndex());
    anchor.setCol2(cell.getColumnIndex() + 1);
    anchor.setRow1(cell.getRowIndex());
    anchor.setRow2(cell.getRowIndex() + 1);
    anchor.setDx1(100);
    anchor.setDx2(1000);
    anchor.setDy1(100);
    anchor.setDy2(1000);

    // Create the comment and set the text+author
    Comment comment = drawing.createCellComment(anchor);
    RichTextString str = factory.createRichTextString(message);
    comment.setString(str);
    comment.setAuthor("TURNUS");
    // Assign the comment to the cell
    cell.setCellComment(comment);
}
项目:poix    文件:ExcelChartBuildService.java   
/**
 * 构建多个图形对象
 * @param dataSourceSheet
 * @param tragetSheet
 * @param graphList
 */
private static void buildExcelChart(Sheet dataSourceSheet, Sheet tragetSheet,
                                    List<ExcelGraph> graphList) {
    int len = graphList.size();
    if (len == 1) {
        buildExcelChart(dataSourceSheet, tragetSheet, graphList.get(0));
    } else {
        int drawStart = 0;
        int drawEnd = 20;
        Drawing drawing = tragetSheet.createDrawingPatriarch();
        for (int i = 0; i < len; i++) {
            ExcelGraph graph = graphList.get(i);
            ClientAnchor anchor = drawing.createAnchor(0, 0, 0, 0, 0, drawStart, 15, drawEnd);
            buildExcelChart(drawing, anchor, dataSourceSheet, graph);
            drawStart = drawStart + drawEnd;
            drawEnd = drawEnd + drawEnd;
        }
    }
}
项目:dataforms    文件:ExcelReport.java   
/**
 * セルに対し画像を設定します。
 * @param c セル。
 * @param value 値。
 * @param p セル位置情報。
 */
private void setImage(final Cell c, final Object value, final CellPosition p) {
    ImageData img = (ImageData) value;
    int cidx = c.getColumnIndex();
    int ridx = c.getRowIndex();
    ClientAnchor anchor = new XSSFClientAnchor();
    anchor.setCol1(cidx);
    anchor.setCol2(cidx + p.getColumns());
    anchor.setRow1(ridx);
    anchor.setRow2(ridx + p.getRows());
    anchor.setDx1(XSSFShape.EMU_PER_PIXEL * p.getDx1());
    anchor.setDy1(XSSFShape.EMU_PER_PIXEL * p.getDy1());
    anchor.setDx2(XSSFShape.EMU_PER_PIXEL * p.getDx2());
    anchor.setDy2(XSSFShape.EMU_PER_PIXEL * p.getDy2());
    anchor.setAnchorType(ClientAnchor.MOVE_AND_RESIZE);
    int imgtype = XSSFWorkbook.PICTURE_TYPE_PNG;
    if (ImageData.CONTENT_TYPE_JPEG.equals(img.getContentType())) {
        imgtype = XSSFWorkbook.PICTURE_TYPE_JPEG;
    } else if (ImageData.CONTENT_TYPE_GIF.equals(img.getContentType())) {
        imgtype = XSSFWorkbook.PICTURE_TYPE_GIF;
    }
    int pidx = this.workbook.addPicture(img.getContents(), imgtype);
    Picture pic = this.drawing.createPicture(anchor, pidx);
    this.resizeImage(c, pic, p);
}
项目:xlsmapper    文件:POIUtils.java   
/**
 * セルのコメントのanchorTypeを設定する。
 * <p>POI-3.15からタイプがint型から列挙型に変わったため、列挙型利用可能であれば自動的に切り替える。</p>
 * @since 1.6
 * @param anchor
 * @param type アンカーのタイプ
 */
public static void setClientAnchorType(final ClientAnchor anchor, final Object type) {

    try {
        final Method method;
        if(AVAILABLE_ANCHOR_TYPE_ENUM) {
            // AnchorTypeが利用可能なとき
            method = ClientAnchor.class.getMethod("setAnchorType", Class.forName("org.apache.poi.ss.usermodel.ClientAnchor$AnchorType"));
        } else {
            method = ClientAnchor.class.getMethod("setAnchorType", int.class);

        }

        method.invoke(anchor, type);

    } catch(Exception e) {
        throw new RuntimeException("fail invoke method ClientAnchor#setAnchorType(type).", e);
    }

}
项目:read-open-source-code    文件:ExcelWriterStep.java   
private Comment createCellComment(String author, String comment) {

        // comments only supported for XLSX
        if (data.sheet instanceof XSSFSheet) {
            CreationHelper factory = data.wb.getCreationHelper();
            Drawing drawing = data.sheet.createDrawingPatriarch();

            ClientAnchor anchor = factory.createClientAnchor();
            Comment cmt = drawing.createCellComment(anchor);
            RichTextString str = factory.createRichTextString(comment);
            cmt.setString(str);
            cmt.setAuthor(author);
            return cmt;

        }
        return null;

    }
项目:kettle-4.4.0-stable    文件:ExcelWriterStep.java   
private Comment createCellComment(String author, String comment) {

        // comments only supported for XLSX
        if (data.sheet instanceof XSSFSheet) {
            CreationHelper factory = data.wb.getCreationHelper();
            Drawing drawing = data.sheet.createDrawingPatriarch();

            ClientAnchor anchor = factory.createClientAnchor();
            Comment cmt = drawing.createCellComment(anchor);
            RichTextString str = factory.createRichTextString(comment);
            cmt.setString(str);
            cmt.setAuthor(author);
            return cmt;

        }
        return null;

    }
项目:kettle-trunk    文件:ExcelWriterStep.java   
private Comment createCellComment(String author, String comment) {

        // comments only supported for XLSX
        if (data.sheet instanceof XSSFSheet) {
            CreationHelper factory = data.wb.getCreationHelper();
            Drawing drawing = data.sheet.createDrawingPatriarch();

            ClientAnchor anchor = factory.createClientAnchor();
            Comment cmt = drawing.createCellComment(anchor);
            RichTextString str = factory.createRichTextString(comment);
            cmt.setString(str);
            cmt.setAuthor(author);
            return cmt;

        }
        return null;

    }
项目:pentaho-kettle    文件:ExcelWriterStep.java   
private Comment createCellComment( String author, String comment ) {

    // comments only supported for XLSX
    if ( data.sheet instanceof XSSFSheet ) {
      CreationHelper factory = data.wb.getCreationHelper();
      Drawing drawing = data.sheet.createDrawingPatriarch();

      ClientAnchor anchor = factory.createClientAnchor();
      Comment cmt = drawing.createCellComment( anchor );
      RichTextString str = factory.createRichTextString( comment );
      cmt.setString( str );
      cmt.setAuthor( author );
      return cmt;

    }
    return null;

  }
项目:PoiExcelExport    文件:ExcelExportService.java   
/**
 * 抽象出图片生成业务代码
 * 
 * @throws IOException
 */
private void extractPicturePortion(String svgString, XSSFWorkbook wb,
        XSSFSheet sheet, int startCol, int endCol, int startRow, int endRow)
        throws IOException {
    // 图片
    if (org.apache.commons.lang3.StringUtils.isNotBlank(svgString)) {
        byte[] safeDataBytes = new BASE64Decoder().decodeBuffer(svgString);
        int pictureIdx = wb.addPicture(safeDataBytes,
                Workbook.PICTURE_TYPE_JPEG);
        CreationHelper helper = wb.getCreationHelper();
        // Create the drawing patriarch. This is the top level container for
        // all shapes.
        Drawing drawing = sheet.createDrawingPatriarch();
        // add a picture shape
        ClientAnchor anchor = helper.createClientAnchor();
        // set top-left corner of the picture,
        // subsequent call of Picture#resize() will operate relative to it
        anchor.setCol1(startCol);
        anchor.setCol2(endCol);
        anchor.setRow1(startRow);
        anchor.setRow2(endRow);
        anchor.setDx1(0);
        anchor.setDy1(0);
        anchor.setDx2(0);
        anchor.setDy2(0);
        anchor.setAnchorType(ClientAnchor.MOVE_DONT_RESIZE);
        Picture pict = drawing.createPicture(anchor, pictureIdx);
        pict.resize(1);
    }
}
项目:PoiExcelExport2.0    文件:ExcelExportService.java   
/**
 * 抽象出图片生成业务代码
 * 
 * @throws IOException
 */
private void extractPicturePortion(String svgString, XSSFWorkbook wb,
        XSSFSheet sheet, int startCol, int endCol, int startRow, int endRow)
        throws IOException {
    // 图片
    if (org.apache.commons.lang3.StringUtils.isNotBlank(svgString)) {
        byte[] safeDataBytes = new BASE64Decoder().decodeBuffer(svgString);
        int pictureIdx = wb.addPicture(safeDataBytes,
                Workbook.PICTURE_TYPE_JPEG);
        CreationHelper helper = wb.getCreationHelper();
        // Create the drawing patriarch. This is the top level container for
        // all shapes.
        Drawing drawing = sheet.createDrawingPatriarch();
        // add a picture shape
        ClientAnchor anchor = helper.createClientAnchor();
        // set top-left corner of the picture,
        // subsequent call of Picture#resize() will operate relative to it
        anchor.setCol1(startCol);
        anchor.setCol2(endCol);
        anchor.setRow1(startRow);
        anchor.setRow2(endRow);
        anchor.setDx1(0);
        anchor.setDy1(0);
        anchor.setDx2(0);
        anchor.setDy2(0);
        anchor.setAnchorType(ClientAnchor.MOVE_DONT_RESIZE);
        Picture pict = drawing.createPicture(anchor, pictureIdx);
        pict.resize(1);
    }
}
项目:poix    文件:ExcelChartBuildService.java   
/**
 * 构建图形对象
 * @param dataSourceSheet
 * @param tragetSheet
 * @param graph
 */
private static void buildExcelChart(Sheet dataSourceSheet, Sheet tragetSheet,
                                    ExcelGraph graph) {
    Drawing drawing = tragetSheet.createDrawingPatriarch();
    ClientAnchor anchor = drawing.createAnchor(0, 0, 0, 0, 0, 0, 15, 20);
    buildExcelChart(drawing, anchor, dataSourceSheet, graph);
}
项目:jasperreports    文件:JRXlsExporter.java   
public static ClientAnchor.AnchorType getAnchorType(ImageAnchorTypeEnum anchorType)
{
    switch (anchorType)
    {
        case MOVE_SIZE: 
            return ClientAnchor.AnchorType.MOVE_AND_RESIZE;
        case NO_MOVE_NO_SIZE:
            return ClientAnchor.AnchorType.DONT_MOVE_AND_RESIZE;
        case MOVE_NO_SIZE:
        default:
            return ClientAnchor.AnchorType.MOVE_DONT_RESIZE;
    }
}
项目:embulk-parser-poi_excel    文件:PoiExcelClientAnchorVisitor.java   
public Object getClientAnchorValue(Column column, Cell cell, ClientAnchor anchor, String key) {
    if (key == null || key.isEmpty()) {
        return getAllValues(column, cell, anchor);
    }

    return getAttributeValue(column, cell, anchor, key);
}
项目:swing    文件:Report.java   
protected void addChart(HSSFWorkbook workbook, byte[] chart, String name) {
    int pictureIndex = workbook.addPicture(chart, HSSFWorkbook.PICTURE_TYPE_PNG);
    HSSFSheet sheet = workbook.createSheet(name);
    addTitle(sheet, name, 0);
    Drawing drawing = sheet.createDrawingPatriarch();
    CreationHelper helper = workbook.getCreationHelper();
    ClientAnchor anchor = helper.createClientAnchor();
    anchor.setRow1(1);
    anchor.setCol1(0);
    Picture picture = drawing.createPicture(anchor, pictureIndex);
    picture.resize();
}
项目:Aspose_for_Apache_POI    文件:ApacheAddImage.java   
public static void main(String[] args) throws Exception
{
    String dataPath = "src/featurescomparison/workingwithworkbook/addimages/data/";

    //create a new workbook
    Workbook wb = new XSSFWorkbook(); //or new HSSFWorkbook();

    //add picture data to this workbook.
    InputStream is = new FileInputStream(dataPath + "aspose.jpg");
    byte[] bytes = IOUtils.toByteArray(is);
    int pictureIdx = wb.addPicture(bytes, Workbook.PICTURE_TYPE_JPEG);
    is.close();

    CreationHelper helper = wb.getCreationHelper();

    //create sheet
    Sheet sheet = wb.createSheet();

    // Create the drawing patriarch.  This is the top level container for all shapes. 
    Drawing drawing = sheet.createDrawingPatriarch();

    //add a picture shape
    ClientAnchor anchor = helper.createClientAnchor();
    //set top-left corner of the picture,
    //subsequent call of Picture#resize() will operate relative to it
    anchor.setCol1(3);
    anchor.setRow1(2);
    Picture pict = drawing.createPicture(anchor, pictureIdx);

    //auto-size picture relative to its top-left corner
    pict.resize();

    //save workbook
    String file = dataPath + "ApacheImage.xls";
    if(wb instanceof XSSFWorkbook) file += "x";
    FileOutputStream fileOut = new FileOutputStream(file);
    wb.write(fileOut);
    fileOut.close();
    System.out.println("Done...");
}
项目:xlsmapper    文件:CellCommentStore.java   
public static AnchorStore get(final ClientAnchor anchor) {
    final AnchorStore anchorStore = new AnchorStore();
    anchorStore.type = anchor.getAnchorType();
    anchorStore.dx1 = anchor.getDx1();
    anchorStore.dx2 = anchor.getDx2();
    anchorStore.dy1 = anchor.getDy1();
    anchorStore.dy2 = anchor.getDy2();

    anchorStore.columnSize = anchor.getCol2() - anchor.getCol1();
    anchorStore.rowSize = anchor.getRow2() - anchor.getRow1();

    return anchorStore;
}
项目:yarg    文件:AbstractInliner.java   
@Override
public void inlineToXls(HSSFPatriarch patriarch, HSSFCell resultCell, Object paramValue, Matcher paramsMatcher) {
    try {
        Image image = new Image(paramValue, paramsMatcher);
        if (image.isValid()) {
            HSSFSheet sheet = resultCell.getSheet();
            HSSFWorkbook workbook = sheet.getWorkbook();

            int pictureIdx = workbook.addPicture(image.imageContent, Workbook.PICTURE_TYPE_JPEG);

            CreationHelper helper = workbook.getCreationHelper();
            ClientAnchor anchor = helper.createClientAnchor();
            anchor.setCol1(resultCell.getColumnIndex());
            anchor.setRow1(resultCell.getRowIndex());
            anchor.setCol2(resultCell.getColumnIndex());
            anchor.setRow2(resultCell.getRowIndex());
            if (patriarch == null) {
                throw new IllegalArgumentException(String.format("No HSSFPatriarch object provided. Charts on this sheet could cause this effect. Please check sheet %s", resultCell.getSheet().getSheetName()));
            }
            HSSFPicture picture = patriarch.createPicture(anchor, pictureIdx);
            Dimension size = ImageUtils.getDimensionFromAnchor(picture);
            double actualHeight = size.getHeight() / EMU_PER_PIXEL;
            double actualWidth = size.getWidth() / EMU_PER_PIXEL;
            picture.resize((double) image.width / actualWidth, (double) image.height / actualHeight);
        }
    } catch (IllegalArgumentException e) {
        throw new ReportFormattingException("An error occurred while inserting bitmap to xls file", e);
    }
}
项目:Runway-SDK    文件:ExcelExportSheet.java   
protected void writeHeader(Sheet sheet, Drawing drawing, Row nameRow, Row labelRow, int i, ExcelColumn column, CellStyle boldStyle)
{
  CreationHelper helper = sheet.getWorkbook().getCreationHelper();

  // Notify the listeners
  for (ExcelExportListener listener : listeners)
  {
    listener.preHeader(column);
  }

  nameRow.createCell(i).setCellValue(helper.createRichTextString(column.getAttributeName()));

  Cell cell = labelRow.createCell(i);
  cell.setCellValue(helper.createRichTextString(column.getDisplayLabel()));

  if (column.isRequired() && boldStyle != null)
  {
    cell.setCellStyle(boldStyle);
  }

  if (column.getDescription() != null && column.getDescription().length() > 0)
  {
    ClientAnchor anchor = helper.createClientAnchor();
    anchor.setDx1(0);
    anchor.setDy1(0);
    anchor.setDx2(0);
    anchor.setDy2(0);
    anchor.setCol1(0);
    anchor.setRow1(0);
    anchor.setCol2(0);
    anchor.setRow2(4);

    Comment comment = drawing.createCellComment(anchor);
    comment.setString(helper.createRichTextString(column.getDescription()));

    cell.setCellComment(comment);
  }

  sheet.autoSizeColumn((short) i);
}
项目:hy.common.report    文件:ImageAreaInfo.java   
public ImageAreaInfo(ClientAnchor i_Anchor ,PictureData i_PictureData)
{
    this.anchor      = i_Anchor;
    this.pictureData = i_PictureData;
}
项目:hy.common.report    文件:ImageAreaInfo.java   
public ClientAnchor getAnchor()
{
    return anchor;
}
项目:hy.common.report    文件:ImageAreaInfo.java   
public void setAnchor(ClientAnchor anchor)
{
    this.anchor = anchor;
}
项目:hadoopoffice    文件:MSExcelWriter.java   
/**
* Add a cell to the current Workbook
*
* @param newDAO cell to add. If it is already existing an exception will be thrown. Note that the sheet name is sanitized using  org.apache.poi.ss.util.WorkbookUtil.createSafeSheetName. The Cell address needs to be in A1 format. Either formula or formattedValue must be not null.
*
*/
@Override
public void write(Object newDAO) throws OfficeWriterException {

    SpreadSheetCellDAO sscd = checkSpreadSheetCellDAO(newDAO);
    String safeSheetName=WorkbookUtil.createSafeSheetName(sscd.getSheetName());
    Sheet currentSheet=this.currentWorkbook.getSheet(safeSheetName);
    if (currentSheet==null) {// create sheet if it does not exist yet
        currentSheet=this.currentWorkbook.createSheet(safeSheetName);
        if (!(safeSheetName.equals(sscd.getSheetName()))) {
            LOG.warn("Sheetname modified from \""+sscd.getSheetName()+"\" to \""+safeSheetName+"\" to correspond to Excel conventions.");
        }
        // create drawing anchor (needed for comments...)
        this.mappedDrawings.put(safeSheetName,currentSheet.createDrawingPatriarch());
    }
    // check if cell exist
    CellAddress currentCA = new CellAddress(sscd.getAddress());
    Row currentRow = currentSheet.getRow(currentCA.getRow());
    if (currentRow==null) { // row does not exist? => create it
        currentRow=currentSheet.createRow(currentCA.getRow());
    }
    Cell currentCell = currentRow.getCell(currentCA.getColumn());
    if ((currentCell!=null) && (this.hasTemplate==false)) { // cell already exists and no template loaded ? => throw exception
        throw new OfficeWriterException("Invalid cell specification: cell already exists at "+currentCA);
    }
    // create cell if no template is loaded or cell not available in template
    if ((this.hasTemplate==false) || (currentCell==null)) {
        currentCell=currentRow.createCell(currentCA.getColumn());       
    }
    // set the values accordingly
    if (!("".equals(sscd.getFormula()))) { // if formula exists then use formula
        currentCell.setCellFormula(sscd.getFormula());

    } else {    
    // else use formattedValue
        currentCell.setCellValue(sscd.getFormattedValue());
    }
    // set comment
    if ((sscd.getComment()!=null) && (!("".equals(sscd.getComment())))) {
        /** the following operations are necessary to create comments **/
        /** Define size of the comment window **/
            ClientAnchor anchor = this.currentWorkbook.getCreationHelper().createClientAnchor();
                anchor.setCol1(currentCell.getColumnIndex());
                anchor.setCol2(currentCell.getColumnIndex()+this.howc.getCommentWidth());
                anchor.setRow1(currentRow.getRowNum());
                anchor.setRow2(currentRow.getRowNum()+this.howc.getCommentHeight());
        /** create comment **/
            Comment currentComment = mappedDrawings.get(safeSheetName).createCellComment(anchor);
                currentComment.setString(this.currentWorkbook.getCreationHelper().createRichTextString(sscd.getComment()));
                currentComment.setAuthor(this.howc.getCommentAuthor());
            currentCell.setCellComment(currentComment);

    }
}
项目:hadoopoffice    文件:MSExcelLowFootprintWriter.java   
@Override
public void write(Object newDAO) throws OfficeWriterException {
    SpreadSheetCellDAO sscd = MSExcelWriter.checkSpreadSheetCellDAO(newDAO);
    String safeSheetName=WorkbookUtil.createSafeSheetName(sscd.getSheetName());
    SXSSFSheet currentSheet=this.currentWorkbook.getSheet(safeSheetName);
    if (currentSheet==null) {// create sheet if it does not exist yet
        currentSheet=this.currentWorkbook.createSheet(safeSheetName);
        if (!(safeSheetName.equals(sscd.getSheetName()))) {
            LOG.warn("Sheetname modified from \""+sscd.getSheetName()+"\" to \""+safeSheetName+"\" to correspond to Excel conventions.");
        }
        // create drawing anchor (needed for comments...)
        this.mappedDrawings.put(safeSheetName,currentSheet.createDrawingPatriarch());
    }
    // check if cell exist
    CellAddress currentCA = new CellAddress(sscd.getAddress());
    SXSSFRow currentRow = currentSheet.getRow(currentCA.getRow());
    if (currentRow==null) { // row does not exist? => create it
        currentRow=currentSheet.createRow(currentCA.getRow());
    }
    SXSSFCell currentCell = currentRow.getCell(currentCA.getColumn());
    if ((currentCell!=null)) { // cell already exists and no template loaded ? => throw exception
        throw new OfficeWriterException("Invalid cell specification: cell already exists at "+currentCA);
    }
    // create cell if no template is loaded or cell not available in template
        currentCell=currentRow.createCell(currentCA.getColumn());       
    // set the values accordingly
    if (!("".equals(sscd.getFormula()))) { // if formula exists then use formula
        currentCell.setCellFormula(sscd.getFormula());

    } else {    
    // else use formattedValue
        currentCell.setCellValue(sscd.getFormattedValue());
    }
    // set comment
    if ((sscd.getComment()!=null) && (!("".equals(sscd.getComment())))) {
        /** the following operations are necessary to create comments **/
        /** Define size of the comment window **/
            ClientAnchor anchor = this.currentWorkbook.getCreationHelper().createClientAnchor();
                anchor.setCol1(currentCell.getColumnIndex());
                anchor.setCol2(currentCell.getColumnIndex()+this.howc.getCommentWidth());
                anchor.setRow1(currentRow.getRowNum());
                anchor.setRow2(currentRow.getRowNum()+this.howc.getCommentHeight());
        /** create comment **/
           Comment currentComment = mappedDrawings.get(safeSheetName).createCellComment(anchor);
                currentComment.setString(this.currentWorkbook.getCreationHelper().createRichTextString(sscd.getComment()));
                currentComment.setAuthor(this.howc.getCommentAuthor());
            currentCell.setCellComment(currentComment);

    }
    }
项目:jasperreports    文件:JRXlsMetadataExporter.java   
public ImageSettings(int index, ClientAnchor.AnchorType anchorType) {
    this.index = index;
    this.anchorType = anchorType;
}
项目:jasperreports    文件:JRXlsMetadataExporter.java   
public ClientAnchor.AnchorType getAnchorType() {
    return anchorType;
}
项目:embulk-parser-poi_excel    文件:PoiExcelClientAnchorVisitor.java   
@Override
protected ClientAnchor getAttributeSource(PoiExcelColumnBean bean, Cell cell) {
    throw new UnsupportedOperationException();
}
项目:embulk-parser-poi_excel    文件:PoiExcelClientAnchorVisitor.java   
@Override
protected Map<String, AttributeSupplier<ClientAnchor>> getAttributeSupplierMap() {
    return SUPPLIER_MAP;
}
项目:embulk-parser-poi_excel    文件:PoiExcelClientAnchorVisitor.java   
@Override
public Object get(Column column, Cell cell, ClientAnchor anchor) {
    return (long) anchor.getAnchorType();
}
项目:embulk-parser-poi_excel    文件:PoiExcelClientAnchorVisitor.java   
@Override
public Object get(Column column, Cell cell, ClientAnchor anchor) {
    return (long) anchor.getCol1();
}
项目:embulk-parser-poi_excel    文件:PoiExcelClientAnchorVisitor.java   
@Override
public Object get(Column column, Cell cell, ClientAnchor anchor) {
    return (long) anchor.getCol2();
}
项目:embulk-parser-poi_excel    文件:PoiExcelClientAnchorVisitor.java   
@Override
public Object get(Column column, Cell cell, ClientAnchor anchor) {
    return (long) anchor.getDx1();
}
项目:embulk-parser-poi_excel    文件:PoiExcelClientAnchorVisitor.java   
@Override
public Object get(Column column, Cell cell, ClientAnchor anchor) {
    return (long) anchor.getDx2();
}
项目:embulk-parser-poi_excel    文件:PoiExcelClientAnchorVisitor.java   
@Override
public Object get(Column column, Cell cell, ClientAnchor anchor) {
    return (long) anchor.getDy1();
}
项目:embulk-parser-poi_excel    文件:PoiExcelClientAnchorVisitor.java   
@Override
public Object get(Column column, Cell cell, ClientAnchor anchor) {
    return (long) anchor.getDy2();
}
项目:embulk-parser-poi_excel    文件:PoiExcelClientAnchorVisitor.java   
@Override
public Object get(Column column, Cell cell, ClientAnchor anchor) {
    return (long) anchor.getRow1();
}
项目:embulk-parser-poi_excel    文件:PoiExcelClientAnchorVisitor.java   
@Override
public Object get(Column column, Cell cell, ClientAnchor anchor) {
    return (long) anchor.getRow2();
}
项目:embulk-parser-poi_excel    文件:PoiExcelCellCommentVisitor.java   
final Object getClientAnchorValue(Column column, Cell cell, Comment comment, String key) {
    ClientAnchor anchor = comment.getClientAnchor();
    PoiExcelVisitorFactory factory = visitorValue.getVisitorFactory();
    PoiExcelClientAnchorVisitor delegator = factory.getPoiExcelClientAnchorVisitor();
    return delegator.getClientAnchorValue(column, cell, anchor, key);
}
项目:birt    文件:PageHandler.java   
/**
 * <p>
 * Process a CellImage from the images list and place the image on the sheet.
 * </p><p>
 * This involves changing the row height as necesssary and determining the column spread of the image.
 * </p>
 * @param cellImage
 * The image to be placed on the sheet.
 */
private void processCellImage( HandlerState state, Drawing drawing, CellImage cellImage ) {
    Coordinate location = cellImage.location;

    Cell cell = state.currentSheet.getRow( location.getRow() ).getCell( location.getCol() );

    IImageContent image = cellImage.image;      

    StyleManagerUtils smu = state.getSmu();
    float ptHeight = cell.getRow().getHeightInPoints();
    if( image.getHeight() != null ) {
        ptHeight = smu.fontSizeInPoints( image.getHeight().toString() );
    }

    // Get image width
    int endCol = cell.getColumnIndex();
       double lastColWidth = ClientAnchorConversions.widthUnits2Millimetres( (short)state.currentSheet.getColumnWidth( endCol ) )
            + 2.0;
       int dx = smu.anchorDxFromMM( lastColWidth, lastColWidth );
       double mmWidth = 0.0;
       if( smu.isAbsolute(image.getWidth())) {
           mmWidth = image.getWidth().convertTo(DimensionType.UNITS_MM);
       } else if(smu.isPixels(image.getWidth())) {
           mmWidth = ClientAnchorConversions.pixels2Millimetres( image.getWidth().getMeasure() );
       }
    // Allow image to span multiple columns
    CellRangeAddress mergedRegion = getMergedRegionBegunBy( state.currentSheet, location.getRow(), location.getCol() );
    if( (cellImage.spanColumns) || ( mergedRegion != null ) ) {
        log.debug( "Image size: ", image.getWidth(), " translates as mmWidth = ", mmWidth );
        if( mmWidth > 0) {
            double mmAccumulatedWidth = 0;
            int endColLimit = cellImage.spanColumns ? 256 : mergedRegion.getLastColumn();
            for( endCol = cell.getColumnIndex(); mmAccumulatedWidth < mmWidth && endCol < endColLimit; ++ endCol ) {
                lastColWidth = ClientAnchorConversions.widthUnits2Millimetres( (short)state.currentSheet.getColumnWidth( endCol ) )
                        + 2.0;
                mmAccumulatedWidth += lastColWidth;
                log.debug( "lastColWidth = ", lastColWidth, "; mmAccumulatedWidth = ", mmAccumulatedWidth);
            }
            if( mmAccumulatedWidth > mmWidth ) {
                mmAccumulatedWidth -= lastColWidth;
                --endCol;
                double mmShort = mmWidth - mmAccumulatedWidth;
                dx = smu.anchorDxFromMM( mmShort, lastColWidth );
            }
        }
    } else {
        float widthRatio = (float)(mmWidth / lastColWidth);
        ptHeight = ptHeight / widthRatio;
    }

    int rowsSpanned = state.findRowsSpanned( cell.getRowIndex(), cell.getColumnIndex() );
    float neededRowHeightPoints = ptHeight;

    for( int i = 0; i < rowsSpanned; ++i ) {
        int rowIndex = cell.getRowIndex() + 1 + i;
        neededRowHeightPoints -= state.currentSheet.getRow(rowIndex).getHeightInPoints();
    }

    if( neededRowHeightPoints > cell.getRow().getHeightInPoints()) {
        cell.getRow().setHeightInPoints( neededRowHeightPoints );
    }

    // ClientAnchor anchor = wb.getCreationHelper().createClientAnchor();
    ClientAnchor anchor = state.getWb().getCreationHelper().createClientAnchor();
       anchor.setCol1(cell.getColumnIndex());
       anchor.setRow1(cell.getRowIndex());
       anchor.setCol2(endCol);
       anchor.setRow2(cell.getRowIndex() + rowsSpanned);
       anchor.setDx2(dx);
       anchor.setDy2( smu.anchorDyFromPoints( ptHeight, cell.getRow().getHeightInPoints() ) );
       anchor.setAnchorType(ClientAnchor.MOVE_DONT_RESIZE);
    drawing.createPicture(anchor, cellImage.imageIdx);
}
项目:xlsmapper    文件:CellCommentStore.java   
/**
 * 保持している情報を元に、シートのセルにコメントを設定する。
 * @param sheet
 * @return POIの設定したコメントオブジェクト。
 * @throws IllegalArgumentException sheet is null.
 */
public Comment set(final Sheet sheet) {
    ArgUtils.notNull(sheet, "sheet");

    final CreationHelper helper = sheet.getWorkbook().getCreationHelper();
    final Drawing drawing = sheet.createDrawingPatriarch();

    // コメントの位置、サイズの指定
    int col1 = column + 1;
    int row1 = row;

    if(sheet instanceof HSSFSheet) {
        // 2003形式の場合は、行の位置をずらす。
        row1--;
    }

    int col2 = col1 + anchor.columnSize;
    int row2 = row1 + anchor.rowSize;
    final ClientAnchor clientAnchor = drawing.createAnchor(
            anchor.dx1, anchor.dy1, anchor.dx2, anchor.dy2,
            col1, row1, col2, row2
            );
    POIUtils.setClientAnchorType(clientAnchor, anchor.type);

    final Comment comment = drawing.createCellComment(clientAnchor);
    comment.setColumn(column);
    comment.setRow(row);
    comment.setAuthor(author);
    comment.setVisible(visible);

    // 装飾を適用する。
    final RichTextString richText = helper.createRichTextString(text.text);
    if(text.fonts != null) {
        for(TextFontStore fontStore : text.fonts) {
            if(fontStore.font != null) {
                richText.applyFont(fontStore.startIndex, fontStore.endIndex, fontStore.font);
            } else {
                richText.applyFont(fontStore.startIndex, fontStore.endIndex, fontStore.fontIndex);
            }
        }
    }

    comment.setString(richText);

    return comment;

}