本文整理汇总了Java中org.apache.poi.ss.usermodel.Picture类的典型用法代码示例。如果您正苦于以下问题:Java Picture类的具体用法?Java Picture怎么用?Java Picture使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Picture类属于org.apache.poi.ss.usermodel包,在下文中一共展示了Picture类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: createDefaultLogo
import org.apache.poi.ss.usermodel.Picture; //导入依赖的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: setImage
import org.apache.poi.ss.usermodel.Picture; //导入依赖的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: computeAxisRowIndex
import org.apache.poi.ss.usermodel.Picture; //导入依赖的package包/类
public static int computeAxisRowIndex(Sheet sheet, Picture picture) {
// Calculates the dimensions in EMUs for the anchor of the given picture
val dimension = ImageUtils.getDimensionFromAnchor(picture);
val halfHeight = dimension.getHeight() / Units.EMU_PER_POINT / 2;
val clientAnchor = picture.getClientAnchor();
val anchorRow1 = clientAnchor.getRow1();
val fromRowHeight = sheet.getRow(anchorRow1).getHeightInPoints();
val anchorDy1 = clientAnchor.getDy1();
val anchorRow2 = clientAnchor.getRow2();
val y1 = sheet instanceof HSSFSheet
? anchorDy1 / 256.0f * fromRowHeight // refer to HSSFClientAnchor.getAnchorHeightInPoints
: anchorDy1 / Units.EMU_PER_POINT;
var sumHeight = fromRowHeight - y1;
if (sumHeight >= halfHeight) return anchorRow1;
for (var i = anchorRow1 + 1; i < anchorRow2; ++i) {
sumHeight += sheet.getRow(i).getHeightInPoints();
if (sumHeight >= halfHeight) return i;
}
return anchorRow2;
}
开发者ID:bingoohuang,项目名称:excel2javabeans,代码行数:25,代码来源:ExcelImages.java
示例4: computeAxisColIndex
import org.apache.poi.ss.usermodel.Picture; //导入依赖的package包/类
public static int computeAxisColIndex(Sheet sheet, Picture picture) {
// Calculates the dimensions in EMUs for the anchor of the given picture
val dimension = ImageUtils.getDimensionFromAnchor(picture); //
val halfWidth = dimension.getHeight() / Units.EMU_PER_PIXEL / 2;
val clientAnchor = picture.getClientAnchor();
val anchorCol1 = clientAnchor.getCol1();
val anchorCol2 = clientAnchor.getCol2();
val anchorDx1 = clientAnchor.getDx1();
val fromColumnWidth = sheet.getColumnWidthInPixels(anchorCol1);
var sumWidth = fromColumnWidth - anchorDx1 / Units.EMU_PER_PIXEL;
if (sumWidth >= halfWidth) return anchorCol1;
for (var i = anchorCol1 + 1; i < anchorCol2; ++i) {
sumWidth += sheet.getColumnWidthInPixels(i);
if (sumWidth >= halfWidth) return i;
}
return anchorCol2;
}
开发者ID:bingoohuang,项目名称:excel2javabeans,代码行数:22,代码来源:ExcelImages.java
示例5: resizeImage
import org.apache.poi.ss.usermodel.Picture; //导入依赖的package包/类
/**
* 画像サイズの調整。
* @param c セル。
* @param pic 画像。
* @param p セル位置情報。
*/
private void resizeImage(final Cell c, final Picture pic, final CellPosition p) {
if ("image".equals(p.getAspect())) {
double w = this.getAnchorWidth(p) - (p.getDx1() - p.getDx2());
double h = this.getAnchorHeight(p) - (p.getDy1() - p.getDy2());
Dimension d = pic.getImageDimension();
log.debug("w,h=" + w + "," + h);
log.debug("iw,ih=" + d.getWidth() + "," + d.getHeight());
if (w > h) {
double cw = w / h;
double iw = d.getWidth() / d.getHeight();
pic.resize((iw / cw) * 1.0, 1.0);
} else {
double ch = h / w;
double ih = d.getHeight() / d.getWidth();
pic.resize(1.0, (ih / ch) * 1.0);
}
}
}
开发者ID:takayanagi2087,项目名称:dataforms,代码行数:25,代码来源:ExcelReport.java
示例6: extractPicturePortion
import org.apache.poi.ss.usermodel.Picture; //导入依赖的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
示例7: addChart
import org.apache.poi.ss.usermodel.Picture; //导入依赖的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
示例8: main
import org.apache.poi.ss.usermodel.Picture; //导入依赖的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
示例9: resizeMarginLeftTop
import org.apache.poi.ss.usermodel.Picture; //导入依赖的package包/类
/**
* 重置图片大小,设置顶部、左侧边距
*
* @author ZhengWei(HY)
* @createDate 2017-10-31
* @version v1.0
*
* @param i_Picture
*/
protected void resizeMarginLeftTop(Picture i_Picture)
{
i_Picture.resize();
i_Picture.getAnchor().setDx1(i_Picture.getAnchor().getDx1() + Help.NVL(this.marginLeft ,0));
i_Picture.getAnchor().setDx2(i_Picture.getAnchor().getDx2() + Help.NVL(this.marginLeft ,0));
i_Picture.getAnchor().setDy1(i_Picture.getAnchor().getDy1() + Help.NVL(this.marginTop ,0));
i_Picture.getAnchor().setDy2(i_Picture.getAnchor().getDy2() + Help.NVL(this.marginTop ,0));
}
开发者ID:HY-ZhengWei,项目名称:hy.common.report,代码行数:18,代码来源:ImageListener.java
注:本文中的org.apache.poi.ss.usermodel.Picture类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论