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


Java XSSFClientAnchor类代码示例

本文整理汇总了Java中org.apache.poi.xssf.usermodel.XSSFClientAnchor的典型用法代码示例。如果您正苦于以下问题:Java XSSFClientAnchor类的具体用法?Java XSSFClientAnchor怎么用?Java XSSFClientAnchor使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


XSSFClientAnchor类属于org.apache.poi.xssf.usermodel包,在下文中一共展示了XSSFClientAnchor类的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getSheetPictrues07

import org.apache.poi.xssf.usermodel.XSSFClientAnchor; //导入依赖的package包/类
/**
 * 获取Excel2007图片
 * 
 * @param sheet
 *            当前sheet对象
 * @param workbook
 *            工作簿对象
 * @return Map key:图片单元格索引(1_1)String,value:图片流PictureData
 */
public static Map<String, PictureData> getSheetPictrues07(XSSFSheet sheet,
                                                          XSSFWorkbook workbook) {
    Map<String, PictureData> sheetIndexPicMap = new HashMap<String, PictureData>();
    for (POIXMLDocumentPart dr : sheet.getRelations()) {
        if (dr instanceof XSSFDrawing) {
            XSSFDrawing drawing = (XSSFDrawing) dr;
            List<XSSFShape> shapes = drawing.getShapes();
            for (XSSFShape shape : shapes) {
                XSSFPicture pic = (XSSFPicture) shape;
                XSSFClientAnchor anchor = pic.getPreferredSize();
                CTMarker ctMarker = anchor.getFrom();
                String picIndex = ctMarker.getRow() + "_" + ctMarker.getCol();
                sheetIndexPicMap.put(picIndex, pic.getPictureData());
            }
        }
    }
    return sheetIndexPicMap;
}
 
开发者ID:rushingpig,项目名称:poix,代码行数:28,代码来源:PoiPublicUtil.java

示例2: setImage

import org.apache.poi.xssf.usermodel.XSSFClientAnchor; //导入依赖的package包/类
/**
 * セルに対し画像を設定します。
 * @param c セル。
 * @param value 値。
 * @param p セル位置情報。
 */
private void setImage(final Cell c, final Object value, final CellPosition p) {
	ImageData img = (ImageData) value;
	int cidx = c.getColumnIndex();
	int ridx = c.getRowIndex();
	ClientAnchor anchor = new XSSFClientAnchor();
	anchor.setCol1(cidx);
	anchor.setCol2(cidx + p.getColumns());
	anchor.setRow1(ridx);
	anchor.setRow2(ridx + p.getRows());
	anchor.setDx1(XSSFShape.EMU_PER_PIXEL * p.getDx1());
	anchor.setDy1(XSSFShape.EMU_PER_PIXEL * p.getDy1());
	anchor.setDx2(XSSFShape.EMU_PER_PIXEL * p.getDx2());
	anchor.setDy2(XSSFShape.EMU_PER_PIXEL * p.getDy2());
	anchor.setAnchorType(ClientAnchor.MOVE_AND_RESIZE);
	int imgtype = XSSFWorkbook.PICTURE_TYPE_PNG;
	if (ImageData.CONTENT_TYPE_JPEG.equals(img.getContentType())) {
		imgtype = XSSFWorkbook.PICTURE_TYPE_JPEG;
	} else if (ImageData.CONTENT_TYPE_GIF.equals(img.getContentType())) {
		imgtype = XSSFWorkbook.PICTURE_TYPE_GIF;
	}
	int pidx = this.workbook.addPicture(img.getContents(), imgtype);
	Picture pic = this.drawing.createPicture(anchor, pidx);
	this.resizeImage(c, pic, p);
}
 
开发者ID:takayanagi2087,项目名称:dataforms,代码行数:31,代码来源:ExcelReport.java

示例3: getSheetPictrues07

import org.apache.poi.xssf.usermodel.XSSFClientAnchor; //导入依赖的package包/类
/**
 * 获取Excel2007图片
 * 
 * @param sheet
 *            当前sheet对象
 * @param workbook
 *            工作簿对象
 * @return Map key:图片单元格索引(1_1)String,value:图片流PictureData
 */
public static Map<String, PictureData> getSheetPictrues07(XSSFSheet sheet, XSSFWorkbook workbook) {
    Map<String, PictureData> sheetIndexPicMap = new HashMap<String, PictureData>();
    for (POIXMLDocumentPart dr : sheet.getRelations()) {
        if (dr instanceof XSSFDrawing) {
            XSSFDrawing drawing = (XSSFDrawing) dr;
            List<XSSFShape> shapes = drawing.getShapes();
            for (XSSFShape shape : shapes) {
                XSSFPicture pic = (XSSFPicture) shape;
                XSSFClientAnchor anchor = pic.getPreferredSize();
                CTMarker ctMarker = anchor.getFrom();
                String picIndex = ctMarker.getRow() + "_" + ctMarker.getCol();
                sheetIndexPicMap.put(picIndex, pic.getPictureData());
            }
        }
    }
    return sheetIndexPicMap;
}
 
开发者ID:xiaolanglang,项目名称:easypoi,代码行数:27,代码来源:PoiPublicUtil.java

示例4: initialize

import org.apache.poi.xssf.usermodel.XSSFClientAnchor; //导入依赖的package包/类
/**
 * 初始化函数
 * @param title 表格标题,传“空值”,表示无标题
 * @param headerList 表头列表
 */
private void initialize(String title, List<String> headerList) {
    this.wb = new SXSSFWorkbook(500);
    this.sheet = wb.createSheet("Export");
    this.styles = createStyles(wb);
    // Create title
    if (StringUtils.isNotBlank(title)){
        Row titleRow = sheet.createRow(rownum++);
        titleRow.setHeightInPoints(30);
        Cell titleCell = titleRow.createCell(0);
        titleCell.setCellStyle(styles.get("title"));
        titleCell.setCellValue(title);
        sheet.addMergedRegion(new CellRangeAddress(titleRow.getRowNum(),
                titleRow.getRowNum(), titleRow.getRowNum(), headerList.size()-1));
    }
    // Create header
    if (headerList == null){
        throw new RuntimeException("headerList not null!");
    }
    Row headerRow = sheet.createRow(rownum++);
    headerRow.setHeightInPoints(16);
    for (int i = 0; i < headerList.size(); i++) {
        Cell cell = headerRow.createCell(i);
        cell.setCellStyle(styles.get("header"));
        String[] ss = StringUtils.split(headerList.get(i), "**", 2);
        if (ss.length==2){
            cell.setCellValue(ss[0]);
            Comment comment = this.sheet.createDrawingPatriarch().createCellComment(
                    new XSSFClientAnchor(0, 0, 0, 0, (short) 3, 3, (short) 5, 6));
            comment.setString(new XSSFRichTextString(ss[1]));
            cell.setCellComment(comment);
        }else{
            cell.setCellValue(headerList.get(i));
        }
        sheet.autoSizeColumn(i);
    }
    for (int i = 0; i < headerList.size(); i++) {
        int colWidth = sheet.getColumnWidth(i)*2;
        sheet.setColumnWidth(i, colWidth < 3000 ? 3000 : colWidth);
    }
    log.debug("Initialize success.");
}
 
开发者ID:sombie007,项目名称:ExcelHandle,代码行数:47,代码来源:ExportExcel.java

示例5: setCellPicture

import org.apache.poi.xssf.usermodel.XSSFClientAnchor; //导入依赖的package包/类
public static void setCellPicture(XSSFWorkbook wb, XSSFSheet sh, byte[] iconBytes, int row, int col) throws Exception {
       int myPictureId = wb.addPicture(iconBytes, XSSFWorkbook.PICTURE_TYPE_PNG);
       
       XSSFDrawing drawing = sh.createDrawingPatriarch();
       XSSFClientAnchor myAnchor = new XSSFClientAnchor();
      
       myAnchor.setCol1(col);
       myAnchor.setRow1(row);
       
       XSSFPicture myPicture = drawing.createPicture(myAnchor, myPictureId);
       myPicture.resize();
}
 
开发者ID:billchen198318,项目名称:bamboobsc,代码行数:13,代码来源:SimpleUtils.java

示例6: initialize

import org.apache.poi.xssf.usermodel.XSSFClientAnchor; //导入依赖的package包/类
/**
     * 初始化函数
     *
     * @param title      表格标题,传“空值”,表示无标题
     * @param headerList 表头列表
     */
    private void initialize(String title, List<String> headerList) {
        this.wb = new SXSSFWorkbook(500);
        this.sheet = wb.createSheet("Export");
        this.styles = createStyles(wb);
        // Create title
        if (StringUtils.isNotBlank(title)) {
            Row titleRow = sheet.createRow(rownum++);
            titleRow.setHeightInPoints(30);
            Cell titleCell = titleRow.createCell(0);
            titleCell.setCellStyle(styles.get("title"));
            titleCell.setCellValue(title);
            sheet.addMergedRegion(new CellRangeAddress(titleRow.getRowNum(),
                    titleRow.getRowNum(), titleRow.getRowNum(), headerList.size() - 1));
        }
        // Create header
        if (headerList == null) {
            throw new RuntimeException("headerList not null!");
        }
        Row headerRow = sheet.createRow(rownum++);
        headerRow.setHeightInPoints(16);
        for (int i = 0; i < headerList.size(); i++) {
            Cell cell = headerRow.createCell(i);
            cell.setCellStyle(styles.get("header"));
            String[] ss = StringUtils.split(headerList.get(i), "**", 2);
            if (ss.length == 2) {
                cell.setCellValue(ss[0]);
                Comment comment = this.sheet.createDrawingPatriarch().createCellComment(
                        new XSSFClientAnchor(0, 0, 0, 0, (short) 3, 3, (short) 5, 6));
                comment.setString(new XSSFRichTextString(ss[1]));
                cell.setCellComment(comment);
            } else {
                cell.setCellValue(headerList.get(i));
            }
//            sheet.autoSizeColumn(i);
        }
        for (int i = 0; i < headerList.size(); i++) {
            int colWidth = sheet.getColumnWidth(i) * 2;
            sheet.setColumnWidth(i, colWidth < 3000 ? 3000 : colWidth);
        }
        log.debug("Initialize success.");
    }
 
开发者ID:guolf,项目名称:pds,代码行数:48,代码来源:ExportExcel.java

示例7: initialize

import org.apache.poi.xssf.usermodel.XSSFClientAnchor; //导入依赖的package包/类
/**
 * 初始化函数
 *
 * @param title      表格标题,传“空值”,表示无标题
 * @param headerList 表头列表
 */
private void initialize(String title, List<String> headerList) {
    this.wb = new SXSSFWorkbook(500);
    this.sheet = wb.createSheet("Export");
    this.styles = createStyles(wb);
    // Create title
    if (StringUtils.isNotBlank(title)) {
        Row titleRow = sheet.createRow(rownum++);
        titleRow.setHeightInPoints(30);
        Cell titleCell = titleRow.createCell(0);
        titleCell.setCellStyle(styles.get("title"));
        titleCell.setCellValue(title);
        sheet.addMergedRegion(new CellRangeAddress(titleRow.getRowNum(),
                titleRow.getRowNum(), titleRow.getRowNum(), headerList.size() - 1));
    }
    // Create header
    if (headerList == null) {
        throw new RuntimeException("headerList not null!");
    }
    Row headerRow = sheet.createRow(rownum++);
    headerRow.setHeightInPoints(16);
    for (int i = 0; i < headerList.size(); i++) {
        Cell cell = headerRow.createCell(i);
        cell.setCellStyle(styles.get("header"));
        String[] ss = StringUtils.split(headerList.get(i), "**", 2);
        if (ss.length == 2) {
            cell.setCellValue(ss[0]);
            Comment comment = this.sheet.createDrawingPatriarch().createCellComment(
                    new XSSFClientAnchor(0, 0, 0, 0, (short) 3, 3, (short) 5, 6));
            comment.setString(new XSSFRichTextString(ss[1]));
            cell.setCellComment(comment);
        } else {
            cell.setCellValue(headerList.get(i));
        }
        sheet.autoSizeColumn(i);
    }
    for (int i = 0; i < headerList.size(); i++) {
        int colWidth = sheet.getColumnWidth(i) * 2;
        sheet.setColumnWidth(i, colWidth < 3000 ? 3000 : colWidth);
    }
    log.debug("Initialize success.");
}
 
开发者ID:guolf,项目名称:pds,代码行数:48,代码来源:ExportExcel.java

示例8: initialize

import org.apache.poi.xssf.usermodel.XSSFClientAnchor; //导入依赖的package包/类
/**
 * 初始化函数
 *
 * @param title      表格标题,传“空值”,表示无标题
 * @param headerList 表头列表
 */
private void initialize(String title, List<String> headerList) {
    this.wb = new SXSSFWorkbook(500);
    this.sheet = wb.createSheet("Export");
    this.styles = createStyles(wb);
    // Create title
    if (StringUtils.isNotBlank(title)) {
        Row titleRow = sheet.createRow(rownum++);
        titleRow.setHeightInPoints(30);
        Cell titleCell = titleRow.createCell(0);
        titleCell.setCellStyle(styles.get("title"));
        titleCell.setCellValue(title);
        sheet.addMergedRegion(new CellRangeAddress(titleRow.getRowNum(), titleRow.getRowNum(), titleRow.getRowNum(),
                headerList.size() - 1));
    }
    // Create header
    if (headerList == null) {
        throw new RuntimeException("headerList not null!");
    }
    Row headerRow = sheet.createRow(rownum++);
    headerRow.setHeightInPoints(16);
    for (int i = 0; i < headerList.size(); i++) {
        Cell cell = headerRow.createCell(i);
        cell.setCellStyle(styles.get("header"));
        String[] ss = StringUtils.split(headerList.get(i), "**", 2);
        if (ss.length == 2) {
            cell.setCellValue(ss[0]);
            Comment comment = this.sheet.createDrawingPatriarch()
                    .createCellComment(new XSSFClientAnchor(0, 0, 0, 0, (short) 3, 3, (short) 5, 6));
            comment.setString(new XSSFRichTextString(ss[1]));
            cell.setCellComment(comment);
        } else {
            cell.setCellValue(headerList.get(i));
        }
        sheet.autoSizeColumn(i);
    }
    for (int i = 0; i < headerList.size(); i++) {
        int colWidth = sheet.getColumnWidth(i) * 2;
        sheet.setColumnWidth(i, colWidth < 3000 ? 3000 : colWidth);
    }
    log.debug("Initialize success.");
}
 
开发者ID:ansafari,项目名称:melon,代码行数:48,代码来源:ExportExcel.java

示例9: initialize

import org.apache.poi.xssf.usermodel.XSSFClientAnchor; //导入依赖的package包/类
/**
 * 初始化函数
 * @param title 表格标题,传“空值”,表示无标题
 * @param headerList 表头列表
 */
private void initialize(String title, List<String> headerList) {
	this.wb = new SXSSFWorkbook(500);
	this.sheet = wb.createSheet("Export");
	this.styles = createStyles(wb);
	// Create title
	if (StringUtils.isNotBlank(title)){
		Row titleRow = sheet.createRow(rownum++);
		titleRow.setHeightInPoints(30);
		Cell titleCell = titleRow.createCell(0);
		titleCell.setCellStyle(styles.get("title"));
		titleCell.setCellValue(title);
		sheet.addMergedRegion(new CellRangeAddress(titleRow.getRowNum(),
				titleRow.getRowNum(), titleRow.getRowNum(), headerList.size()-1));
	}
	// Create header
	if (headerList == null){
		throw new RuntimeException("headerList not null!");
	}
	Row headerRow = sheet.createRow(rownum++);
	headerRow.setHeightInPoints(16);
	for (int i = 0; i < headerList.size(); i++) {
		Cell cell = headerRow.createCell(i);
		cell.setCellStyle(styles.get("header"));
		String[] ss = StringUtils.split(headerList.get(i), "**", 2);
		if (ss.length==2){
			cell.setCellValue(ss[0]);
			Comment comment = this.sheet.createDrawingPatriarch().createCellComment(
					new XSSFClientAnchor(0, 0, 0, 0, (short) 3, 3, (short) 5, 6));
			comment.setString(new XSSFRichTextString(ss[1]));
			cell.setCellComment(comment);
		}else{
			cell.setCellValue(headerList.get(i));
		}
		sheet.autoSizeColumn(i);
	}
	for (int i = 0; i < headerList.size(); i++) {  
		int colWidth = sheet.getColumnWidth(i)*2;
        sheet.setColumnWidth(i, colWidth < 3000 ? 3000 : colWidth);  
	}
	log.debug("Initialize success.");
}
 
开发者ID:EleTeam,项目名称:Shop-for-JavaWeb,代码行数:47,代码来源:ExportExcel.java

示例10: addComment

import org.apache.poi.xssf.usermodel.XSSFClientAnchor; //导入依赖的package包/类
/**
 * 특정셀에 코멘트를 추가한다.
 *
 * @param sheet
 * @param cell
 * @param commentText
 * @return
 */
public static void addComment(Sheet sheet, Cell cell, String commentText) {
	XSSFDrawing patr = (XSSFDrawing) sheet.createDrawingPatriarch();
	Comment comment = patr.createCellComment(new XSSFClientAnchor(0, 0, 0, 0, (short) 4, 2, (short) 6, 5));
	comment.setString(new XSSFRichTextString(commentText));
	cell.setCellComment(comment);
}
 
开发者ID:callakrsos,项目名称:Gargoyle,代码行数:15,代码来源:ExcelUtil.java

示例11: copyClientAnchor

import org.apache.poi.xssf.usermodel.XSSFClientAnchor; //导入依赖的package包/类
/**
 * 复制锚。用于2007的Excel文件
 * 
 * @author      ZhengWei(HY)
 * @createDate  2017-03-19
 * @version     v1.0
 *
 * @param i_FromAnchor
 * @param i_ToAnchor
 * @param i_OffsetRow     偏移行号
 */
public final static void copyClientAnchor(XSSFClientAnchor i_FromAnchor ,XSSFClientAnchor i_ToAnchor ,int i_OffsetRow)
{
    copyCTMarker(i_FromAnchor.getFrom() ,i_ToAnchor.getFrom() ,i_OffsetRow);
    copyCTMarker(i_FromAnchor.getTo()   ,i_ToAnchor.getTo()   ,i_OffsetRow);
}
 
开发者ID:HY-ZhengWei,项目名称:hy.common.report,代码行数:17,代码来源:ExcelHelp.java


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