本文整理了Java中org.apache.poi.hssf.usermodel.HSSFSheet.createDrawingPatriarch()
方法的一些代码示例,展示了HSSFSheet.createDrawingPatriarch()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。HSSFSheet.createDrawingPatriarch()
方法的具体详情如下:
包路径:org.apache.poi.hssf.usermodel.HSSFSheet
类名称:HSSFSheet
方法名:createDrawingPatriarch
[英]Creates the top-level drawing patriarch. This will have the effect of removing any existing drawings on this sheet. This may then be used to add graphics or charts
[中]创建顶级图形父对象。这将产生删除此图纸上任何现有图纸的效果。然后,可以使用此选项添加图形或图表
代码示例来源: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
private void moveCommentsForRowShift(int startRow, int endRow, int n) {
final HSSFPatriarch patriarch = createDrawingPatriarch();
for (final HSSFShape shape : patriarch.getChildren()) {
if (!(shape instanceof HSSFComment)) {
continue;
}
final HSSFComment comment = (HSSFComment) shape;
final int r = comment.getRow();
if (startRow <= r && r <= endRow) {
comment.setRow(clip(r + n));
}
}
}
代码示例来源:origin: org.apache.poi/poi
HSSFPatriarch p = createDrawingPatriarch();
final int firstColumn = range.getFirstColumn();
final int lastColumn = range.getLastColumn();
代码示例来源:origin: com.haulmont.yarg/yarg
protected void copyCharts(HSSFSheet resultSheet) {
HSSFChart[] sheetCharts = HSSFChart.getSheetCharts(resultSheet);
if (sheetCharts == null || sheetCharts.length == 0) {//workaround for charts. If there is charts on sheet - we can not use getDrawPatriarch as it removes all charts (because does not support them)
HSSFPatriarch drawingPatriarch = resultSheet.createDrawingPatriarch();
if (drawingPatriarch == null) {
drawingPatriarch = resultSheet.createDrawingPatriarch();
}
drawingPatriarchsMap.put(resultSheet, drawingPatriarch);
}
}
代码示例来源:origin: cuba-platform/yarg
protected void copyCharts(HSSFSheet resultSheet) {
HSSFChart[] sheetCharts = HSSFChart.getSheetCharts(resultSheet);
if (sheetCharts == null || sheetCharts.length == 0) {//workaround for charts. If there is charts on sheet - we can not use getDrawPatriarch as it removes all charts (because does not support them)
HSSFPatriarch drawingPatriarch = resultSheet.createDrawingPatriarch();
if (drawingPatriarch == null) {
drawingPatriarch = resultSheet.createDrawingPatriarch();
}
drawingPatriarchsMap.put(resultSheet, drawingPatriarch);
}
}
代码示例来源: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: 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: 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: com.github.mg365/mg-common
private void createPicture(HSSFWorkbook workBook,MObjectExportVo exportVo,List<String> picturesList) throws IOException {
for (int i = 0; i < picturesList.size(); i++) {
HSSFSheet sheet = workBook.getSheetAt(i);
if(StringUtils.isBlank(picturesList.get(i))){
continue;
}
//String picture = "C:\\jira\\person.png"; //要插入的图片,可为png、jpg格式
String picture = PropertyConfigurer.getContextProperty("temppath") + picturesList.get(i);
ByteArrayOutputStream bos = new ByteArrayOutputStream();
BufferedImage BufferImg = ImageIO.read(new File(picture));
ImageIO.write(BufferImg, "PNG", bos);
HSSFPatriarch patriarch = sheet.createDrawingPatriarch();//创建绘图工具对象
int col1 = exportVo.getStartCol(); //起始单元格列序号;
int row1 = exportVo.getStartRow(); //起始单元格行序号;
int col2 = exportVo.getEndCol(); //终止单元格列序号;
int row2 = exportVo.getEndRow(); //终止单元格行序号;
HSSFClientAnchor anchor = new HSSFClientAnchor(0, 0, 0, 0, (short) col1, row1, (short) col2, row2);
patriarch.createPicture(anchor, workBook.addPicture(bos.toByteArray(), workBook.PICTURE_TYPE_PNG));
}
}
代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.poi
private void moveCommentsForRowShift(int startRow, int endRow, int n) {
final HSSFPatriarch patriarch = createDrawingPatriarch();
for (final HSSFShape shape : patriarch.getChildren()) {
if (!(shape instanceof HSSFComment)) {
continue;
}
final HSSFComment comment = (HSSFComment) shape;
final int r = comment.getRow();
if (startRow <= r && r <= endRow) {
comment.setRow(clip(r + n));
}
}
}
代码示例来源:origin: stackoverflow.com
public void setComment(String text, Cell cell) {
final Map<Sheet, HSSFPatriarch> drawingPatriarches = new HashMap<Sheet, HSSFPatriarch>();
CreationHelper createHelper = cell.getSheet().getWorkbook().getCreationHelper();
HSSFSheet sheet = (HSSFSheet) cell.getSheet();
HSSFPatriarch drawingPatriarch = drawingPatriarches.get(sheet);
if (drawingPatriarch == null) {
drawingPatriarch = sheet.createDrawingPatriarch();
drawingPatriarches.put(sheet, drawingPatriarch);
}
Comment comment = drawingPatriarch.createComment(new HSSFClientAnchor(0, 0, 0, 0, (short) 4, 2, (short) 6, 5));
comment.setString(createHelper.createRichTextString(text));
cell.setCellComment(comment);
}
代码示例来源:origin: org.apache.poi/poi-examples
private static void drawSheet2( HSSFSheet sheet2 )
{
// Create a row and size one of the cells reasonably large.
HSSFRow row = sheet2.createRow(2);
row.createCell(1);
row.setHeightInPoints(240);
sheet2.setColumnWidth(2, 9000);
// Create the drawing patriarch. This is the top level container for
// all shapes. This will clear out any existing shapes for that sheet.
HSSFPatriarch patriarch = sheet2.createDrawingPatriarch();
// Draw a grid in one of the cells.
drawGrid( patriarch );
}
代码示例来源:origin: io.choerodon/choerodon-starter-core
/**
* list中数据填充到excel中,headers字段要和javaBean的字段对应,否则写不进去值,headers是驼峰或下划线
*
* @param propertyMap key:JavaBean的字段名, value: 自定义的excel标题头
* @param list
* @param book
* @param sheet
* @param <T>
*/
public static <T> void fillInExcel(Map<String, String> propertyMap, List<T> list, HSSFWorkbook book, HSSFSheet sheet, Class<T> clazz)
throws NoSuchMethodException, IllegalAccessException, InvocationTargetException {
//设置列头样式(居中、变粗、蓝色)
HSSFCellStyle headerStyle = book.createCellStyle();
setHeaderStyle(headerStyle, book);
// 设置单元格样式
HSSFCellStyle cellStyle = book.createCellStyle();
setCellStyle(cellStyle, book);
// 创建头部
Map<String, Integer> headerRow = createHeader(sheet, headerStyle, propertyMap);
// 画图的顶级管理器,一个sheet只能获取一个(一定要注意这点)
HSSFPatriarch patriarch = sheet.createDrawingPatriarch();
processCell(list, book, sheet, clazz, cellStyle, headerRow, patriarch);
}
代码示例来源:origin: choerodon/choerodon-starters
/**
* list中数据填充到excel中,headers字段要和javaBean的字段对应,否则写不进去值,headers是驼峰或下划线
*
* @param propertyMap key:JavaBean的字段名, value: 自定义的excel标题头
* @param list
* @param book
* @param sheet
* @param <T>
*/
public static <T> void fillInExcel(Map<String, String> propertyMap, List<T> list, HSSFWorkbook book, HSSFSheet sheet, Class<T> clazz)
throws NoSuchMethodException, IllegalAccessException, InvocationTargetException {
//设置列头样式(居中、变粗、蓝色)
HSSFCellStyle headerStyle = book.createCellStyle();
setHeaderStyle(headerStyle, book);
// 设置单元格样式
HSSFCellStyle cellStyle = book.createCellStyle();
setCellStyle(cellStyle, book);
// 创建头部
Map<String, Integer> headerRow = createHeader(sheet, headerStyle, propertyMap);
// 画图的顶级管理器,一个sheet只能获取一个(一定要注意这点)
HSSFPatriarch patriarch = sheet.createDrawingPatriarch();
processCell(list, book, sheet, clazz, cellStyle, headerRow, patriarch);
}
代码示例来源:origin: jasperreports/jasperreports
protected void createSheet(String name)
{
sheet = workbook.createSheet(name);
patriarch = sheet.createDrawingPatriarch();
sheet.getPrintSetup().setLandscape(jasperPrint.getOrientation() == JRReport.ORIENTATION_LANDSCAPE);
short paperSize = getSuitablePaperSize(jasperPrint);
if(paperSize != -1)
{
sheet.getPrintSetup().setPaperSize(paperSize);
}
if(password != null)
{
sheet.protectSheet(password);
}
}
代码示例来源:origin: org.apache.poi/poi-examples
private static void drawSheet1( HSSFSheet sheet1 )
{
// Create a row and size one of the cells reasonably large.
HSSFRow row = sheet1.createRow(2);
row.setHeight((short) 2800);
row.createCell(1);
sheet1.setColumnWidth(2, 9000);
// Create the drawing patriarch. This is the top level container for
// all shapes.
HSSFPatriarch patriarch = sheet1.createDrawingPatriarch();
// Draw some lines and an oval.
drawLinesToCenter( patriarch );
drawManyLines( patriarch );
drawOval( patriarch );
drawPolygon( patriarch );
// Draw a rectangle.
HSSFSimpleShape rect = patriarch.createSimpleShape( new HSSFClientAnchor(100, 100, 900, 200, (short)0, 0, (short)0, 0) );
rect.setShapeType(HSSFSimpleShape.OBJECT_TYPE_RECTANGLE);
}
代码示例来源:origin: org.apache.poi/poi-examples
private static void drawSheet5( HSSFSheet sheet5, HSSFWorkbook wb ) throws IOException
{
// Create the drawing patriarch. This is the top level container for
// all shapes. This will clear out any existing shapes for that sheet.
HSSFPatriarch patriarch = sheet5.createDrawingPatriarch();
HSSFClientAnchor anchor;
anchor = new HSSFClientAnchor(0,0,0,255,(short)2,2,(short)4,7);
anchor.setAnchorType( AnchorType.MOVE_DONT_RESIZE );
patriarch.createPicture(anchor, loadPicture( "src/resources/logos/logoKarmokar4.png", wb ));
anchor = new HSSFClientAnchor(0,0,0,255,(short)4,2,(short)5,7);
anchor.setAnchorType( AnchorType.MOVE_DONT_RESIZE );
patriarch.createPicture(anchor, loadPicture( "src/resources/logos/logoKarmokar4edited.png", wb ));
anchor = new HSSFClientAnchor(0,0,1023,255,(short)6,2,(short)8,7);
anchor.setAnchorType( AnchorType.MOVE_DONT_RESIZE );
HSSFPicture picture = patriarch.createPicture(anchor, loadPicture( "src/resources/logos/logoKarmokar4s.png", wb ));
//Reset the image to the original size.
picture.resize();
picture.setLineStyle( HSSFShape.LINESTYLE_DASHDOTGEL );
}
代码示例来源:origin: org.apache.poi/poi-examples
private static void drawSheet3( HSSFSheet sheet3 )
{
// Create a row and size one of the cells reasonably large
HSSFRow row = sheet3.createRow(2);
row.setHeightInPoints(140);
row.createCell(1);
sheet3.setColumnWidth(2, 9000);
// Create the drawing patriarch. This is the top level container for
// all shapes. This will clear out any existing shapes for that sheet.
HSSFPatriarch patriarch = sheet3.createDrawingPatriarch();
// Create a shape group.
HSSFShapeGroup group = patriarch.createGroup(
new HSSFClientAnchor(0,0,900,200,(short)2,2,(short)2,2));
// Create a couple of lines in the group.
HSSFSimpleShape shape1 = group.createShape(new HSSFChildAnchor(3,3,500,500));
shape1.setShapeType(HSSFSimpleShape.OBJECT_TYPE_LINE);
( (HSSFChildAnchor) shape1.getAnchor() ).setAnchor((short)3,3,500,500);
HSSFSimpleShape shape2 = group.createShape(new HSSFChildAnchor((short)1,200,400,600));
shape2.setShapeType(HSSFSimpleShape.OBJECT_TYPE_LINE);
}
代码示例来源:origin: com.haulmont.thirdparty/poi
public HSSFAutoFilter setAutoFilter(CellRangeAddress range) {
InternalWorkbook workbook = _workbook.getWorkbook();
int sheetIndex = _workbook.getSheetIndex(this);
NameRecord name = workbook.getSpecificBuiltinRecord(NameRecord.BUILTIN_FILTER_DB, sheetIndex + 1);
if (name == null) {
name = workbook.createBuiltInName(NameRecord.BUILTIN_FILTER_DB, sheetIndex + 1);
}
// The built-in name must consist of a single Area3d Ptg.
Area3DPtg ptg = new Area3DPtg(range.getFirstRow(), range.getLastRow(),
range.getFirstColumn(), range.getLastColumn(),
false, false, false, false, sheetIndex);
name.setNameDefinition(new Ptg[]{ptg});
AutoFilterInfoRecord r = new AutoFilterInfoRecord();
// the number of columns that have AutoFilter enabled.
int numcols = 1 + range.getLastColumn() - range.getFirstColumn();
r.setNumEntries((short) numcols);
int idx = _sheet.findFirstRecordLocBySid(DimensionsRecord.sid);
_sheet.getRecords().add(idx, r);
//create a combobox control for each column
HSSFPatriarch p = createDrawingPatriarch();
for (int col = range.getFirstColumn(); col <= range.getLastColumn(); col++) {
p.createComboBox(new HSSFClientAnchor(0, 0, 0, 0,
(short) col, range.getFirstRow(), (short) (col + 1), range.getFirstRow() + 1));
}
return new HSSFAutoFilter(this);
}
内容来源于网络,如有侵权,请联系作者删除!