當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。