org.apache.poi.ss.usermodel.Drawing类的使用及代码示例

x33g5p2x  于2022-01-18 转载在 其他  
字(9.1k)|赞(0)|评价(0)|浏览(799)

本文整理了Java中org.apache.poi.ss.usermodel.Drawing类的一些代码示例,展示了Drawing类的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Drawing类的具体详情如下:
包路径:org.apache.poi.ss.usermodel.Drawing
类名称:Drawing

Drawing介绍

[英]High level representation of spreadsheet drawing.
[中]电子表格图形的高级表示。

代码示例

代码示例来源:origin: kiegroup/optaplanner

void nextMeetingAssignmentListCell(List<MeetingAssignment> meetingAssignmentList,
    Function<MeetingAssignment, String> stringFunction, List<String> filteredConstraintNames) {
  if (meetingAssignmentList == null) {
    meetingAssignmentList = Collections.emptyList();
  }
  HardMediumSoftScore score = meetingAssignmentList.stream()
      .map(indictmentMap::get).filter(Objects::nonNull)
      .flatMap(indictment -> indictment.getConstraintMatchSet().stream())
      // Filter out filtered constraints
      .filter(constraintMatch -> filteredConstraintNames == null
          || filteredConstraintNames.contains(constraintMatch.getConstraintName()))
      .map(constraintMatch -> (HardMediumSoftScore) constraintMatch.getScore())
      // Filter out positive constraints
      .filter(indictmentScore -> !(indictmentScore.getHardScore() >= 0 && indictmentScore.getSoftScore() >= 0))
      .reduce(Score::add).orElse(HardMediumSoftScore.ZERO);
  XSSFCell cell = getXSSFCellOfScore(score);
  if (!meetingAssignmentList.isEmpty()) {
    ClientAnchor anchor = creationHelper.createClientAnchor();
    anchor.setCol1(cell.getColumnIndex());
    anchor.setCol2(cell.getColumnIndex() + 4);
    anchor.setRow1(currentRow.getRowNum());
    anchor.setRow2(currentRow.getRowNum() + 4);
    Comment comment = currentDrawing.createCellComment(anchor);
    String commentString = getMeetingAssignmentListString(meetingAssignmentList);
    comment.setString(creationHelper.createRichTextString(commentString));
    cell.setCellComment(comment);
  }
  cell.setCellValue(meetingAssignmentList.stream().map(stringFunction).collect(joining("\n")));
  currentRow.setHeightInPoints(Math.max(currentRow.getHeightInPoints(), meetingAssignmentList.size() * currentSheet.getDefaultRowHeightInPoints()));
}

代码示例来源:origin: youseries/ureport

anchor.setDy1(0 * XSSFShape.EMU_PER_PIXEL);
    anchor.setDy2(height * XSSFShape.EMU_PER_PIXEL);
    drawing.createPicture(anchor, pictureIndex);
  }finally{
    IOUtils.closeQuietly(inputStream);
      anchor.setDy1(0 * XSSFShape.EMU_PER_PIXEL);
      anchor.setDy2(height * XSSFShape.EMU_PER_PIXEL);
      drawing.createPicture(anchor, pictureIndex);
    }finally{
      IOUtils.closeQuietly(inputStream);
  anchor.setDy1(0 * XSSFShape.EMU_PER_PIXEL);
  anchor.setDy2(height * XSSFShape.EMU_PER_PIXEL);
  drawing.createPicture(anchor, pictureIndex);
}finally{
  IOUtils.closeQuietly(inputStream);
    anchor.setDy1(0 * XSSFShape.EMU_PER_PIXEL);
    anchor.setDy2(height * XSSFShape.EMU_PER_PIXEL);
    drawing.createPicture(anchor, pictureIndex);
  }finally{
    IOUtils.closeQuietly(inputStream);

代码示例来源:origin: com.sqlapp/sqlapp-core

public static void setComment(CreationHelper helper, Cell cell, String text){
  int dx1 = 200, dy1 = 100, dx2 = 200, dy2 = 100;
  int col1 = cell.getColumnIndex() + 1;
  int row1 = cell.getRowIndex();
  int col2 = col1 + 3;
  String[] args=text.split("\n");
  int row2 = row1 + args.length+1;
  Drawing<?> drawing = cell.getSheet().createDrawingPatriarch();
  ClientAnchor anchor = drawing.createAnchor(dx1, dy1, dx2, dy2, col1, row1, col2, row2);
  Comment comment = drawing.createCellComment(anchor);
  //comment.setAuthor(author);
  comment.setString(helper.createRichTextString(text));
  cell.setCellComment(comment);
}

代码示例来源:origin: stackoverflow.com

ClientAnchor anchor = drawing.createAnchor(0, 0, 0, 0, 0, 5, 5, 20);
Chart chart = drawing.createChart(anchor);

代码示例来源:origin: cn.afterturn/easypoi-base

/**
 * 构建图形对象
 * @param dataSourceSheet
 * @param tragetSheet
 * @param graph
 */
private static void buildExcelChart(Sheet dataSourceSheet,Sheet tragetSheet,ExcelGraph graph){
  Drawing drawing = PoiExcelGraphDataUtil.getDrawingPatriarch(tragetSheet);
  ClientAnchor anchor = drawing.createAnchor(0, 0, 0, 0, 0, 0, 15, 20);
  buildExcelChart(drawing, anchor, dataSourceSheet, graph);
}

代码示例来源:origin: org.jeecg/easypoi-base

Chart chart = drawing.createChart(anchor);
ChartLegend legend = chart.getOrCreateLegend();
legend.setPosition(LegendPosition.TOP_RIGHT);

代码示例来源:origin: youseries/ureport

anchor.setDy1(topMargin * XSSFShape.EMU_PER_PIXEL);
  anchor.setDy2(height * XSSFShape.EMU_PER_PIXEL);
  drawing.createPicture(anchor, pictureIndex);
}finally{
  IOUtils.closeQuietly(inputStream);
    anchor.setDy1(topMargin * XSSFShape.EMU_PER_PIXEL);
    anchor.setDy2(height * XSSFShape.EMU_PER_PIXEL);
    drawing.createPicture(anchor, pictureIndex);
  }finally{
    IOUtils.closeQuietly(inputStream);

代码示例来源:origin: stackoverflow.com

ClientAnchor anchor = drawing.createAnchor(0, 0, 0, 0, 0, 5, 10, 15);
Chart chart = drawing.createChart(anchor);
ChartLegend legend = chart.getOrCreateLegend();
legend.setPosition(LegendPosition.TOP_RIGHT);

代码示例来源:origin: org.jeecg/easypoi-base

/**
 * 构建图形对象
 * @param workbook
 * @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);
}

代码示例来源:origin: kiegroup/optaplanner

anchor.setRow1(currentRow.getRowNum());
anchor.setRow2(currentRow.getRowNum() + 4);
Comment comment = currentDrawing.createCellComment(anchor);
StringBuilder commentString = new StringBuilder(talkList.size() * 200);
for (Talk talk : talkList) {

代码示例来源:origin: youseries/ureport

anchor.setDy1(topMargin * XSSFShape.EMU_PER_PIXEL);
  anchor.setDy2(height * XSSFShape.EMU_PER_PIXEL);
  drawing.createPicture(anchor, pictureIndex);
}finally{
  IOUtils.closeQuietly(inputStream);
    anchor.setDy1(topMargin * XSSFShape.EMU_PER_PIXEL);
    anchor.setDy2(height * XSSFShape.EMU_PER_PIXEL);
    drawing.createPicture(anchor, pictureIndex);
  }finally{
    IOUtils.closeQuietly(inputStream);

代码示例来源:origin: stackoverflow.com

ClientAnchor anchor = drawing.createAnchor(0, 0, 0, 0, 0, 5, 8, 20);
Chart chart = drawing.createChart(anchor);

代码示例来源:origin: cn.afterturn/easypoi-base

/**
 * 构建多个图形对象
 * @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 = PoiExcelGraphDataUtil.getDrawingPatriarch(tragetSheet);
    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;
    }
  }
}

代码示例来源:origin: pentaho/pentaho-kettle

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;
}

代码示例来源:origin: stackoverflow.com

FileInputStream fis = new FileInputStream(imagePath);
   int b;
   byte[] bytes = IOUtils.toByteArray(fis);
   fis.close();
   // This will insert the picture from start cell to end cell of excel
   // sheet.
   HSSFClientAnchor anchor = new HSSFClientAnchor(0, 0, 0, 0,
       start.getCol(), start.getRow(), end.getCol(), end.getRow());
   anchor.setAnchorType(2);
   int index = wb.addPicture(bytes, HSSFWorkbook.PICTURE_TYPE_JPEG);
   // Create the drawing patriarch. This is the top level container for all shapes. 
   Drawing patriarch = sheet.createDrawingPatriarch();
   try {
     HSSFPicture picture = patriarch.createPicture(anchor, index);
     // picture.resize();
   } catch (Exception e) {
     String err = e.getMessage();
   }

代码示例来源:origin: org.jeecg/easypoi-base

/**
 * 构建多个图形对象
 * @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;
    }
  }
}

代码示例来源:origin: stackoverflow.com

Drawing drawing_master = sheet_master.createDrawingPatriarch();
Comment comment_master = drawing_master.createCellComment(anchor);
comment_master.setString(row_slave_a.getCell(0).getCellComment().getString());
row_master_a.createCell(0).setCellComment(comment_master);

代码示例来源:origin: stackoverflow.com

anchor.setRow1(2);
drawing.createPicture(anchor, pictureureIdx);

代码示例来源:origin: org.optaplanner/optaplanner-examples

anchor.setRow1(currentRow.getRowNum());
anchor.setRow2(currentRow.getRowNum() + 4);
Comment comment = currentDrawing.createCellComment(anchor);
StringBuilder commentString = new StringBuilder(talkList.size() * 200);
for (Talk talk : talkList) {

代码示例来源:origin: stackoverflow.com

LOGO_MARGIN = 2;
int index = getLogoPictureIndex();
CreationHelper helper = this.wb.getCreationHelper();

Drawing drawing = this.sheet.createDrawingPatriarch();
ClientAnchor anchor = helper.createClientAnchor();

anchor.setDx1(LOGO_MARGIN * XSSFShape.EMU_PER_PIXEL);
anchor.setDy1(LOGO_MARGIN * XSSFShape.EMU_PER_PIXEL);

Picture pic = drawing.createPicture(anchor, index);
pic.resize(0.064);

相关文章