当前位置: 首页>>代码示例>>Java>>正文


Java HSSFSheet.createDrawingPatriarch方法代码示例

本文整理汇总了Java中org.apache.poi.hssf.usermodel.HSSFSheet.createDrawingPatriarch方法的典型用法代码示例。如果您正苦于以下问题:Java HSSFSheet.createDrawingPatriarch方法的具体用法?Java HSSFSheet.createDrawingPatriarch怎么用?Java HSSFSheet.createDrawingPatriarch使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.poi.hssf.usermodel.HSSFSheet的用法示例。


在下文中一共展示了HSSFSheet.createDrawingPatriarch方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: insertItemToSheet

import org.apache.poi.hssf.usermodel.HSSFSheet; //导入方法依赖的package包/类
private void insertItemToSheet(String table, HSSFSheet sheet, ArrayList<String> columns) {
    HSSFPatriarch patriarch = sheet.createDrawingPatriarch();
    Cursor cursor = database.rawQuery("select * from " + table, null);
    cursor.moveToFirst();
    int n = 1;
    while (!cursor.isAfterLast()) {
        HSSFRow rowA = sheet.createRow(n);
        for (int j = 0; j < columns.size(); j++) {
            HSSFCell cellA = rowA.createCell(j);
            if (cursor.getType(j) == Cursor.FIELD_TYPE_BLOB) {
                HSSFClientAnchor anchor = new HSSFClientAnchor(0, 0, 0, 0, (short) j, n, (short) (j + 1), n + 1);
                anchor.setAnchorType(3);
                patriarch.createPicture(anchor, workbook.addPicture(cursor.getBlob(j), HSSFWorkbook.PICTURE_TYPE_JPEG));
            } else {
                cellA.setCellValue(new HSSFRichTextString(cursor.getString(j)));
            }
        }
        n++;
        cursor.moveToNext();
    }
    cursor.close();
}
 
开发者ID:androidmads,项目名称:SQLite2XL,代码行数:23,代码来源:SQLiteToExcel.java

示例2: setImage

import org.apache.poi.hssf.usermodel.HSSFSheet; //导入方法依赖的package包/类
private void setImage(final HSSFWorkbook workbook, final HSSFSheet sheet, final CellLocation cellLocation, int width, int height) {
    POIUtils.setCellValue(sheet, cellLocation, "");

    if (imageBuffer != null) {
        final HSSFPatriarch patriarch = sheet.createDrawingPatriarch();

        final HSSFPicture picture = patriarch.createPicture(new HSSFClientAnchor(), pictureIndex);

        final Dimension dimension = picture.getImageDimension();
        final float rate = (float) dimension.width / (float) dimension.height;
        final float specifiedRate = (float) width / (float) height;

        if (width == -1 || height == -1) {
            width = dimension.width;
            height = dimension.height;

        } else {
            if (rate > specifiedRate) {
                if (dimension.width > width) {
                    height = (int) (width / rate);

                } else {
                    width = dimension.width;
                    height = dimension.height;
                }

            } else {
                if (dimension.height > height) {
                    width = (int) (height * rate);

                } else {
                    width = dimension.width;
                    height = dimension.height;
                }
            }
        }

        final HSSFClientAnchor preferredSize = getPreferredSize(sheet, new HSSFClientAnchor(0, 0, 0, 0, (short) cellLocation.c, cellLocation.r, (short) 0, 0), width, height);
        picture.setAnchor(preferredSize);
    }
}
 
开发者ID:roundrop,项目名称:ermasterr,代码行数:42,代码来源:PictureSheetGenerator.java

示例3: setImage

import org.apache.poi.hssf.usermodel.HSSFSheet; //导入方法依赖的package包/类
private void setImage(HSSFWorkbook workbook, HSSFSheet sheet,
		CellLocation cellLocation, int width, int height) {
	POIUtils.setCellValue(sheet, cellLocation, "");

	if (this.imageBuffer != null) {
		HSSFPatriarch patriarch = sheet.createDrawingPatriarch();

		HSSFPicture picture = patriarch.createPicture(
				new HSSFClientAnchor(), this.pictureIndex);

		Dimension dimension = picture.getImageDimension();
		float rate = (float) dimension.width / (float) dimension.height;
		float specifiedRate = (float) width / (float) height;

		if (width == -1 || height == -1) {
			width = dimension.width;
			height = dimension.height;
			
		} else {
			if (rate > specifiedRate) {
				if (dimension.width > width) {
					height = (int) (width / rate);

				} else {
					width = dimension.width;
					height = dimension.height;
				}

			} else {
				if (dimension.height > height) {
					width = (int) (height * rate);

				} else {
					width = dimension.width;
					height = dimension.height;
				}
			}
		}

		HSSFClientAnchor preferredSize = this.getPreferredSize(sheet,
				new HSSFClientAnchor(0, 0, 0, 0, (short) cellLocation.c,
						cellLocation.r, (short) 0, 0), width, height);
		picture.setAnchor(preferredSize);
	}
}
 
开发者ID:kozake,项目名称:ermaster-k,代码行数:46,代码来源:PictureSheetGenerator.java


注:本文中的org.apache.poi.hssf.usermodel.HSSFSheet.createDrawingPatriarch方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。