org.apache.poi.hssf.usermodel.HSSFSheet.getDrawingPatriarch()方法的使用及代码示例

x33g5p2x  于2022-01-20 转载在 其他  
字(9.6k)|赞(0)|评价(0)|浏览(471)

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

HSSFSheet.getDrawingPatriarch介绍

[英]Returns the top-level drawing patriach, if there is one. This will hold any graphics or charts for the sheet. WARNING - calling this will trigger a parsing of the associated escher records. Any that aren't supported (such as charts and complex drawing types) will almost certainly be lost or corrupted when written out. Only use this with simple drawings, otherwise call HSSFSheet#createDrawingPatriarch() and start from scratch!
[中]返回顶级图形patrich(如果有)。这将保存工作表的任何图形或图表。警告-调用此命令将触发对相关escher记录的解析。任何不受支持的内容(如图表和复杂图形类型)在写出时几乎肯定会丢失或损坏。仅在简单图形中使用此选项,否则请调用HSSFSheet#CreateDrawingPachur()并从头开始!

代码示例

代码示例来源:origin: org.apache.poi/poi

/**
 * Gets all embedded OLE2 objects from the Workbook.
 *
 * @param sheet embedded object attached to
 * @param objects the list of embedded objects to populate.
 */
private void getAllEmbeddedObjects(HSSFSheet sheet, List<HSSFObjectData> objects)
{
  HSSFPatriarch patriarch = sheet.getDrawingPatriarch();
  if (null == patriarch){
    return;
  }
  getAllEmbeddedObjects(patriarch, objects);
}
/**

代码示例来源:origin: org.apache.poi/poi

void initDrawings(){
  DrawingManager2 mgr = workbook.findDrawingGroup();
  if(mgr != null) {
    for(HSSFSheet sh : _sheets)  {
      sh.getDrawingPatriarch();
    }
  } else {
    workbook.createDrawingGroup();
  }
}

代码示例来源:origin: org.apache.poi/poi

protected HSSFComment findCellComment(int row, int column) {
  HSSFPatriarch patriarch = getDrawingPatriarch();
  if (null == patriarch) {
    patriarch = createDrawingPatriarch();
  }
  return lookForComment(patriarch, row, column);
}

代码示例来源:origin: org.apache.poi/poi

/**
 * Returns all cell comments on this sheet.
 * @return A map of each Comment in the sheet, keyed on the cell address where
 * the comment is located.
 */
@Override
public Map<CellAddress, HSSFComment> getCellComments() {
  HSSFPatriarch patriarch = getDrawingPatriarch();
  if (null == patriarch) {
    patriarch = createDrawingPatriarch();
  }
  
  Map<CellAddress, HSSFComment> locations = new TreeMap<>();
  findCellCommentLocations(patriarch, locations);
  return locations;
}
/**

代码示例来源:origin: org.apache.poi/poi

HSSFSheet cloneSheet(HSSFWorkbook workbook) {
  // Aggregate drawing records
  this.getDrawingPatriarch();
  HSSFSheet sheet = new HSSFSheet(workbook, _sheet.cloneSheet());
  int pos = sheet._sheet.findFirstRecordLocBySid(DrawingRecord.sid);
  DrawingRecord dr = (DrawingRecord) sheet._sheet.findFirstRecordBySid(DrawingRecord.sid);
  if (null != dr) {
    sheet._sheet.getRecords().remove(dr);
  }
  if (getDrawingPatriarch() != null) {
    HSSFPatriarch patr = HSSFPatriarch.createPatriarch(this.getDrawingPatriarch(), sheet);
    sheet._sheet.getRecords().add(pos, patr.getBoundAggregate());
    sheet._patriarch = patr;
  }
  return sheet;
}

代码示例来源:origin: org.apache.poi/poi

HSSFSheet sheet = wb.getSheetAt(i);
if(initDrawing) {
  /*HSSFPatriarch dg =*/ sheet.getDrawingPatriarch();

代码示例来源:origin: org.apache.poi/poi

public static void writeToFile(OutputStream fos, InputStream xlsWorkbook, boolean excludeWorkbookRecords, String[] params) throws IOException {
  HSSFWorkbook workbook = new HSSFWorkbook(xlsWorkbook);
  InternalWorkbook internalWorkbook = workbook.getInternalWorkbook();
  DrawingGroupRecord r = (DrawingGroupRecord) internalWorkbook.findFirstRecordBySid(DrawingGroupRecord.sid);
  StringBuilder builder = new StringBuilder();
  builder.append("<workbook>\n");
  String tab = "\t";
  if (!excludeWorkbookRecords && r != null) {
    r.decode();
    List<EscherRecord> escherRecords = r.getEscherRecords();
    for (EscherRecord record : escherRecords) {
      builder.append(record.toXml(tab));
    }
  }
  List<Integer> sheets = getSheetsIndexes(params, workbook);
  for (Integer i : sheets) {
    HSSFPatriarch p = workbook.getSheetAt(i).getDrawingPatriarch();
    if(p != null ) {
      builder.append(tab).append("<sheet").append(i).append(">\n");
      builder.append(p.getBoundAggregate().toXml(tab + "\t"));
      builder.append(tab).append("</sheet").append(i).append(">\n");
    }
  }
  builder.append("</workbook>\n");
  fos.write(builder.toString().getBytes(StringUtil.UTF8));
  fos.close();
  workbook.close();
}

代码示例来源:origin: org.apache.poi/poi

/**
 * Removes the comment for this cell, if
 *  there is one.
 * WARNING - some versions of excel will loose
 *  all comments after performing this action!
 */
public void removeCellComment() {
  HSSFComment comment = _sheet.findCellComment(_record.getRow(), _record.getColumn());
  _comment = null;
  if (null == comment){
    return;
  }
  _sheet.getDrawingPatriarch().removeShape(comment);
}

代码示例来源:origin: looly/hutool

/**
 * 获取XLS工作簿指定sheet中图片列表
 * 
 * @param workbook 工作簿{@link Workbook}
 * @param sheetIndex sheet的索引
 * @return 图片映射,键格式:行_列,值:{@link PictureData}
 */
private static Map<String, PictureData> getPicMapXls(HSSFWorkbook workbook, int sheetIndex) {
  final Map<String, PictureData> picMap = new HashMap<>();
  final List<HSSFPictureData> pictures = workbook.getAllPictures();
  if (CollectionUtil.isNotEmpty(pictures)) {
    final HSSFSheet sheet = workbook.getSheetAt(sheetIndex);
    HSSFClientAnchor anchor;
    int pictureIndex;
    for (HSSFShape shape : sheet.getDrawingPatriarch().getChildren()) {
      if (shape instanceof HSSFPicture) {
        pictureIndex = ((HSSFPicture) shape).getPictureIndex() - 1;
        anchor = (HSSFClientAnchor) shape.getAnchor();
        picMap.put(StrUtil.format("{}_{}", anchor.getRow1(), anchor.getCol1()), pictures.get(pictureIndex));
      }
    }
  }
  return picMap;
}

代码示例来源:origin: looly/hutool

/**
 * 获取XLS工作簿指定sheet中图片列表
 * 
 * @param workbook 工作簿{@link Workbook}
 * @param sheetIndex sheet的索引
 * @return 图片映射,键格式:行_列,值:{@link PictureData}
 */
private static Map<String, PictureData> getPicMapXls(HSSFWorkbook workbook, int sheetIndex) {
  final Map<String, PictureData> picMap = new HashMap<>();
  final List<HSSFPictureData> pictures = workbook.getAllPictures();
  if (CollectionUtil.isNotEmpty(pictures)) {
    final HSSFSheet sheet = workbook.getSheetAt(sheetIndex);
    HSSFClientAnchor anchor;
    int pictureIndex;
    for (HSSFShape shape : sheet.getDrawingPatriarch().getChildren()) {
      if (shape instanceof HSSFPicture) {
        pictureIndex = ((HSSFPicture) shape).getPictureIndex() - 1;
        anchor = (HSSFClientAnchor) shape.getAnchor();
        picMap.put(StrUtil.format("{}_{}", anchor.getRow1(), anchor.getCol1()), pictures.get(pictureIndex));
      }
    }
  }
  return picMap;
}

代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.poi

/**
 * Gets all embedded OLE2 objects from the Workbook.
 *
 * @param sheet embedded object attached to
 * @param objects the list of embedded objects to populate.
 */
private void getAllEmbeddedObjects(HSSFSheet sheet, List<HSSFObjectData> objects)
{
  HSSFPatriarch patriarch = sheet.getDrawingPatriarch();
  if (null == patriarch){
    return;
  }
  getAllEmbeddedObjects(patriarch, objects);
}
/**

代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.poi

/**
 * Returns all cell comments on this sheet.
 * @return A map of each Comment in the sheet, keyed on the cell address where
 * the comment is located.
 */
@Override
public Map<CellAddress, HSSFComment> getCellComments() {
  HSSFPatriarch patriarch = getDrawingPatriarch();
  if (null == patriarch) {
    patriarch = createDrawingPatriarch();
  }
  
  Map<CellAddress, HSSFComment> locations = new TreeMap<>();
  findCellCommentLocations(patriarch, locations);
  return locations;
}
/**

代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.poi

protected HSSFComment findCellComment(int row, int column) {
  HSSFPatriarch patriarch = getDrawingPatriarch();
  if (null == patriarch) {
    patriarch = createDrawingPatriarch();
  }
  return lookForComment(patriarch, row, column);
}

代码示例来源:origin: com.haulmont.thirdparty/poi

protected HSSFComment findCellComment(int row, int column) {
  HSSFPatriarch patriarch = getDrawingPatriarch();
  if (null == patriarch) {
    patriarch = createDrawingPatriarch();
  }
  return lookForComment(patriarch, row, column);
}

代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.poi

void initDrawings(){
  DrawingManager2 mgr = workbook.findDrawingGroup();
  if(mgr != null) {
    for(HSSFSheet sh : _sheets)  {
      sh.getDrawingPatriarch();
    }
  } else {
    workbook.createDrawingGroup();
  }
}

代码示例来源:origin: com.haulmont.thirdparty/poi

HSSFSheet cloneSheet(HSSFWorkbook workbook) {
  this.getDrawingPatriarch();/**Aggregate drawing records**/
  HSSFSheet sheet = new HSSFSheet(workbook, _sheet.cloneSheet());
  int pos = sheet._sheet.findFirstRecordLocBySid(DrawingRecord.sid);
  DrawingRecord dr = (DrawingRecord) sheet._sheet.findFirstRecordBySid(DrawingRecord.sid);
  if (null != dr) {
    sheet._sheet.getRecords().remove(dr);
  }
  if (getDrawingPatriarch() != null) {
    HSSFPatriarch patr = HSSFPatriarch.createPatriarch(this.getDrawingPatriarch(), sheet);
    sheet._sheet.getRecords().add(pos, patr._getBoundAggregate());
    sheet._patriarch = patr;
  }
  return sheet;
}

代码示例来源:origin: com.haulmont.thirdparty/poi

void initDrawings(){
  DrawingManager2 mgr = workbook.findDrawingGroup();
  if(mgr != null) {
    for(int i=0; i < getNumberOfSheets(); i++)  {
      getSheetAt(i).getDrawingPatriarch();
    }
  } else {
    workbook.createDrawingGroup();
  }
}

代码示例来源:origin: org.openl.rules/org.openl.lib.poi.dev

void initDrawings(){
  DrawingManager2 mgr = workbook.findDrawingGroup();
  if(mgr != null) {
    for(int i=0; i < getNumberOfSheets(); i++)  {
      getSheetAt(i).getDrawingPatriarch();
    }
  } else {
    workbook.createDrawingGroup();
  }
}

代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.poi

/**
 * Removes the comment for this cell, if
 *  there is one.
 * WARNING - some versions of excel will loose
 *  all comments after performing this action!
 */
public void removeCellComment() {
  HSSFComment comment = _sheet.findCellComment(_record.getRow(), _record.getColumn());
  _comment = null;
  if (null == comment){
    return;
  }
  _sheet.getDrawingPatriarch().removeShape(comment);
}

代码示例来源:origin: com.haulmont.thirdparty/poi

/**
 * Removes the comment for this cell, if
 *  there is one.
 * WARNING - some versions of excel will loose
 *  all comments after performing this action!
 */
public void removeCellComment() {
  HSSFComment comment = _sheet.findCellComment(_record.getRow(), _record.getColumn());
  _comment = null;
  if (null == comment){
    return;
  }
  _sheet.getDrawingPatriarch().removeShape(comment);
}

相关文章

微信公众号

最新文章

更多

HSSFSheet类方法