當前位置: 首頁>>代碼示例>>Java>>正文


Java CreationHelper.createClientAnchor方法代碼示例

本文整理匯總了Java中org.apache.poi.ss.usermodel.CreationHelper.createClientAnchor方法的典型用法代碼示例。如果您正苦於以下問題:Java CreationHelper.createClientAnchor方法的具體用法?Java CreationHelper.createClientAnchor怎麽用?Java CreationHelper.createClientAnchor使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.apache.poi.ss.usermodel.CreationHelper的用法示例。


在下文中一共展示了CreationHelper.createClientAnchor方法的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: createDefaultLogo

import org.apache.poi.ss.usermodel.CreationHelper; //導入方法依賴的package包/類
/**
 * @작성자 : KYJ
 * @작성일 : 2016. 9. 9. 
 * @param sheet
 * @throws Exception
 */
final static void createDefaultLogo(Sheet sheet) throws Exception {
	Workbook workbook = sheet.getWorkbook();
	byte[] defaultLogoImage = getDefaultLogoImage();
	if(defaultLogoImage == null)
		return;
	int pictureIdx = workbook.addPicture(defaultLogoImage, Workbook.PICTURE_TYPE_PNG);

	CreationHelper creationHelper = workbook.getCreationHelper();
	ClientAnchor anchor = creationHelper.createClientAnchor(); //new XSSFClientAnchor();
	//			anchor.setAnchorType(AnchorType.MOVE_DONT_RESIZE);
	Drawing createDrawingPatriarch = sheet.createDrawingPatriarch();
	anchor.setDx1(0);
	anchor.setCol1(0);
	anchor.setRow1(0);

	//#1 테이블 셀의 너비에 의존적이지않게 사이즈조절.
	anchor.setAnchorType(AnchorType.MOVE_DONT_RESIZE);
	Picture createPicture = createDrawingPatriarch.createPicture(anchor, pictureIdx);
	//#2 테이블 셀의 너비에 의존적이지않게 사이즈조절.
	createPicture.resize();
}
 
開發者ID:callakrsos,項目名稱:Gargoyle,代碼行數:28,代碼來源:FxExcelUtil.java

示例2: setComment

import org.apache.poi.ss.usermodel.CreationHelper; //導入方法依賴的package包/類
/**
 * See the comment for the given cell
 * 
 * @param cell
 *            the cell
 * @param message
 *            the comment message
 */
public static void setComment(HSSFCell cell, String message) {
	Drawing drawing = cell.getSheet().createDrawingPatriarch();
	CreationHelper factory = cell.getSheet().getWorkbook().getCreationHelper();

	// When the comment box is visible, have it show in a 1x3 space
	ClientAnchor anchor = factory.createClientAnchor();
	anchor.setCol1(cell.getColumnIndex());
	anchor.setCol2(cell.getColumnIndex() + 1);
	anchor.setRow1(cell.getRowIndex());
	anchor.setRow2(cell.getRowIndex() + 1);
	anchor.setDx1(100);
	anchor.setDx2(1000);
	anchor.setDy1(100);
	anchor.setDy2(1000);

	// Create the comment and set the text+author
	Comment comment = drawing.createCellComment(anchor);
	RichTextString str = factory.createRichTextString(message);
	comment.setString(str);
	comment.setAuthor("TURNUS");
	// Assign the comment to the cell
	cell.setCellComment(comment);
}
 
開發者ID:turnus,項目名稱:turnus,代碼行數:32,代碼來源:PoiUtils.java

示例3: createCellComment

import org.apache.poi.ss.usermodel.CreationHelper; //導入方法依賴的package包/類
private Comment createCellComment(String author, String comment) {

		// comments only supported for XLSX
		if (data.sheet instanceof XSSFSheet) {
			CreationHelper factory = data.wb.getCreationHelper();
			Drawing drawing = data.sheet.createDrawingPatriarch();

			ClientAnchor anchor = factory.createClientAnchor();
			Comment cmt = drawing.createCellComment(anchor);
			RichTextString str = factory.createRichTextString(comment);
			cmt.setString(str);
			cmt.setAuthor(author);
			return cmt;

		}
		return null;

	}
 
開發者ID:yintaoxue,項目名稱:read-open-source-code,代碼行數:19,代碼來源:ExcelWriterStep.java

示例4: createCellComment

import org.apache.poi.ss.usermodel.CreationHelper; //導入方法依賴的package包/類
private Comment createCellComment( String author, String comment ) {

    // comments only supported for XLSX
    if ( data.sheet instanceof XSSFSheet ) {
      CreationHelper factory = data.wb.getCreationHelper();
      Drawing drawing = data.sheet.createDrawingPatriarch();

      ClientAnchor anchor = factory.createClientAnchor();
      Comment cmt = drawing.createCellComment( anchor );
      RichTextString str = factory.createRichTextString( comment );
      cmt.setString( str );
      cmt.setAuthor( author );
      return cmt;

    }
    return null;

  }
 
開發者ID:pentaho,項目名稱:pentaho-kettle,代碼行數:19,代碼來源:ExcelWriterStep.java

示例5: extractPicturePortion

import org.apache.poi.ss.usermodel.CreationHelper; //導入方法依賴的package包/類
/**
 * 抽象出圖片生成業務代碼
 * 
 * @throws IOException
 */
private void extractPicturePortion(String svgString, XSSFWorkbook wb,
		XSSFSheet sheet, int startCol, int endCol, int startRow, int endRow)
		throws IOException {
	// 圖片
	if (org.apache.commons.lang3.StringUtils.isNotBlank(svgString)) {
		byte[] safeDataBytes = new BASE64Decoder().decodeBuffer(svgString);
		int pictureIdx = wb.addPicture(safeDataBytes,
				Workbook.PICTURE_TYPE_JPEG);
		CreationHelper helper = wb.getCreationHelper();
		// Create the drawing patriarch. This is the top level container for
		// all shapes.
		Drawing drawing = sheet.createDrawingPatriarch();
		// add a picture shape
		ClientAnchor anchor = helper.createClientAnchor();
		// set top-left corner of the picture,
		// subsequent call of Picture#resize() will operate relative to it
		anchor.setCol1(startCol);
		anchor.setCol2(endCol);
		anchor.setRow1(startRow);
		anchor.setRow2(endRow);
		anchor.setDx1(0);
		anchor.setDy1(0);
		anchor.setDx2(0);
		anchor.setDy2(0);
		anchor.setAnchorType(ClientAnchor.MOVE_DONT_RESIZE);
		Picture pict = drawing.createPicture(anchor, pictureIdx);
		pict.resize(1);
	}
}
 
開發者ID:gp15237125756,項目名稱:PoiExcelExport,代碼行數:35,代碼來源:ExcelExportService.java

示例6: addChart

import org.apache.poi.ss.usermodel.CreationHelper; //導入方法依賴的package包/類
protected void addChart(HSSFWorkbook workbook, byte[] chart, String name) {
    int pictureIndex = workbook.addPicture(chart, HSSFWorkbook.PICTURE_TYPE_PNG);
    HSSFSheet sheet = workbook.createSheet(name);
    addTitle(sheet, name, 0);
    Drawing drawing = sheet.createDrawingPatriarch();
    CreationHelper helper = workbook.getCreationHelper();
    ClientAnchor anchor = helper.createClientAnchor();
    anchor.setRow1(1);
    anchor.setCol1(0);
    Picture picture = drawing.createPicture(anchor, pictureIndex);
    picture.resize();
}
 
開發者ID:objektwerks,項目名稱:swing,代碼行數:13,代碼來源:Report.java

示例7: main

import org.apache.poi.ss.usermodel.CreationHelper; //導入方法依賴的package包/類
public static void main(String[] args) throws Exception
{
	String dataPath = "src/featurescomparison/workingwithworkbook/addimages/data/";
	
	//create a new workbook
    Workbook wb = new XSSFWorkbook(); //or new HSSFWorkbook();

    //add picture data to this workbook.
    InputStream is = new FileInputStream(dataPath + "aspose.jpg");
    byte[] bytes = IOUtils.toByteArray(is);
    int pictureIdx = wb.addPicture(bytes, Workbook.PICTURE_TYPE_JPEG);
    is.close();

    CreationHelper helper = wb.getCreationHelper();

    //create sheet
    Sheet sheet = wb.createSheet();

    // Create the drawing patriarch.  This is the top level container for all shapes. 
    Drawing drawing = sheet.createDrawingPatriarch();

    //add a picture shape
    ClientAnchor anchor = helper.createClientAnchor();
    //set top-left corner of the picture,
    //subsequent call of Picture#resize() will operate relative to it
    anchor.setCol1(3);
    anchor.setRow1(2);
    Picture pict = drawing.createPicture(anchor, pictureIdx);

    //auto-size picture relative to its top-left corner
    pict.resize();

    //save workbook
    String file = dataPath + "ApacheImage.xls";
    if(wb instanceof XSSFWorkbook) file += "x";
    FileOutputStream fileOut = new FileOutputStream(file);
    wb.write(fileOut);
    fileOut.close();
    System.out.println("Done...");
}
 
開發者ID:asposemarketplace,項目名稱:Aspose_for_Apache_POI,代碼行數:41,代碼來源:ApacheAddImage.java

示例8: inlineToXls

import org.apache.poi.ss.usermodel.CreationHelper; //導入方法依賴的package包/類
@Override
public void inlineToXls(HSSFPatriarch patriarch, HSSFCell resultCell, Object paramValue, Matcher paramsMatcher) {
    try {
        Image image = new Image(paramValue, paramsMatcher);
        if (image.isValid()) {
            HSSFSheet sheet = resultCell.getSheet();
            HSSFWorkbook workbook = sheet.getWorkbook();

            int pictureIdx = workbook.addPicture(image.imageContent, Workbook.PICTURE_TYPE_JPEG);

            CreationHelper helper = workbook.getCreationHelper();
            ClientAnchor anchor = helper.createClientAnchor();
            anchor.setCol1(resultCell.getColumnIndex());
            anchor.setRow1(resultCell.getRowIndex());
            anchor.setCol2(resultCell.getColumnIndex());
            anchor.setRow2(resultCell.getRowIndex());
            if (patriarch == null) {
                throw new IllegalArgumentException(String.format("No HSSFPatriarch object provided. Charts on this sheet could cause this effect. Please check sheet %s", resultCell.getSheet().getSheetName()));
            }
            HSSFPicture picture = patriarch.createPicture(anchor, pictureIdx);
            Dimension size = ImageUtils.getDimensionFromAnchor(picture);
            double actualHeight = size.getHeight() / EMU_PER_PIXEL;
            double actualWidth = size.getWidth() / EMU_PER_PIXEL;
            picture.resize((double) image.width / actualWidth, (double) image.height / actualHeight);
        }
    } catch (IllegalArgumentException e) {
        throw new ReportFormattingException("An error occurred while inserting bitmap to xls file", e);
    }
}
 
開發者ID:cuba-platform,項目名稱:yarg,代碼行數:30,代碼來源:AbstractInliner.java

示例9: writeHeader

import org.apache.poi.ss.usermodel.CreationHelper; //導入方法依賴的package包/類
protected void writeHeader(Sheet sheet, Drawing drawing, Row nameRow, Row labelRow, int i, ExcelColumn column, CellStyle boldStyle)
{
  CreationHelper helper = sheet.getWorkbook().getCreationHelper();

  // Notify the listeners
  for (ExcelExportListener listener : listeners)
  {
    listener.preHeader(column);
  }

  nameRow.createCell(i).setCellValue(helper.createRichTextString(column.getAttributeName()));

  Cell cell = labelRow.createCell(i);
  cell.setCellValue(helper.createRichTextString(column.getDisplayLabel()));

  if (column.isRequired() && boldStyle != null)
  {
    cell.setCellStyle(boldStyle);
  }

  if (column.getDescription() != null && column.getDescription().length() > 0)
  {
    ClientAnchor anchor = helper.createClientAnchor();
    anchor.setDx1(0);
    anchor.setDy1(0);
    anchor.setDx2(0);
    anchor.setDy2(0);
    anchor.setCol1(0);
    anchor.setRow1(0);
    anchor.setCol2(0);
    anchor.setRow2(4);

    Comment comment = drawing.createCellComment(anchor);
    comment.setString(helper.createRichTextString(column.getDescription()));

    cell.setCellComment(comment);
  }

  sheet.autoSizeColumn((short) i);
}
 
開發者ID:terraframe,項目名稱:Runway-SDK,代碼行數:41,代碼來源:ExcelExportSheet.java


注:本文中的org.apache.poi.ss.usermodel.CreationHelper.createClientAnchor方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。