本文整理汇总了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();
}
示例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);
}
}
示例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);
}
}