本文整理匯總了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);
}
}