本文整理汇总了Java中org.apache.poi.ss.usermodel.PictureData类的典型用法代码示例。如果您正苦于以下问题:Java PictureData类的具体用法?Java PictureData怎么用?Java PictureData使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
PictureData类属于org.apache.poi.ss.usermodel包,在下文中一共展示了PictureData类的16个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: getSheetPictrues07
import org.apache.poi.ss.usermodel.PictureData; //导入依赖的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: getSheetPictrues03
import org.apache.poi.ss.usermodel.PictureData; //导入依赖的package包/类
/**
* 获取Excel2003图片
*
* @param sheet
* 当前sheet对象
* @param workbook
* 工作簿对象
* @return Map key:图片单元格索引(1_1)String,value:图片流PictureData
*/
public static Map<String, PictureData> getSheetPictrues03(HSSFSheet sheet,
HSSFWorkbook workbook) {
Map<String, PictureData> sheetIndexPicMap = new HashMap<String, PictureData>();
List<HSSFPictureData> pictures = workbook.getAllPictures();
if (!pictures.isEmpty()) {
for (HSSFShape shape : sheet.getDrawingPatriarch().getChildren()) {
HSSFClientAnchor anchor = (HSSFClientAnchor) shape.getAnchor();
if (shape instanceof HSSFPicture) {
HSSFPicture pic = (HSSFPicture) shape;
int pictureIndex = pic.getPictureIndex() - 1;
HSSFPictureData picData = pictures.get(pictureIndex);
String picIndex = String.valueOf(anchor.getRow1()) + "_"
+ String.valueOf(anchor.getCol1());
sheetIndexPicMap.put(picIndex, picData);
}
}
return sheetIndexPicMap;
} else {
return sheetIndexPicMap;
}
}
开发者ID:rushingpig,项目名称:poix,代码行数:31,代码来源:PoiPublicUtil.java
示例3: getSheetPictrues03
import org.apache.poi.ss.usermodel.PictureData; //导入依赖的package包/类
/**
* 获取Excel2003图片
*
* @param sheet
* 当前sheet对象
* @param workbook
* 工作簿对象
* @return Map key:图片单元格索引(1_1)String,value:图片流PictureData
*/
public static Map<String, PictureData> getSheetPictrues03(HSSFSheet sheet, HSSFWorkbook workbook) {
Map<String, PictureData> sheetIndexPicMap = new HashMap<String, PictureData>();
List<HSSFPictureData> pictures = workbook.getAllPictures();
if (!pictures.isEmpty()) {
for (HSSFShape shape : sheet.getDrawingPatriarch().getChildren()) {
HSSFClientAnchor anchor = (HSSFClientAnchor) shape.getAnchor();
if (shape instanceof HSSFPicture) {
HSSFPicture pic = (HSSFPicture) shape;
int pictureIndex = pic.getPictureIndex() - 1;
HSSFPictureData picData = pictures.get(pictureIndex);
String picIndex = String.valueOf(anchor.getRow1()) + "_"
+ String.valueOf(anchor.getCol1());
sheetIndexPicMap.put(picIndex, picData);
}
}
return sheetIndexPicMap;
} else {
return null;
}
}
开发者ID:xiaolanglang,项目名称:easypoi,代码行数:30,代码来源:PoiPublicUtil.java
示例4: getSheetPictrues07
import org.apache.poi.ss.usermodel.PictureData; //导入依赖的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
示例5: addListContinue
import org.apache.poi.ss.usermodel.PictureData; //导入依赖的package包/类
/***
* 向List里面继续添加元素
*
* @param object
* @param param
* @param row
* @param titlemap
* @param targetId
* @param pictures
* @param params
*/
private void addListContinue(Object object, ExcelCollectionParams param, Row row,
Map<Integer, String> titlemap, String targetId,
Map<String, PictureData> pictures,
ImportParams params) throws Exception {
Collection collection = (Collection) PoiReflectorUtil.fromCache(object.getClass())
.getValue(object, param.getName());
Object entity = PoiPublicUtil.createObject(param.getType(), targetId);
String picId;
boolean isUsed = false;// 是否需要加上这个对象
for (int i = row.getFirstCellNum(); i < param.getExcelParams().size(); i++) {
Cell cell = row.getCell(i);
String titleString = (String) titlemap.get(i);
if (param.getExcelParams().containsKey(titleString)) {
if (param.getExcelParams().get(titleString).getType() == 2) {
picId = row.getRowNum() + "_" + i;
saveImage(object, picId, param.getExcelParams(), titleString, pictures, params);
} else {
saveFieldValue(params, entity, cell, param.getExcelParams(), titleString, row);
}
isUsed = true;
}
}
if (isUsed) {
collection.add(entity);
}
}
开发者ID:rushingpig,项目名称:poix,代码行数:38,代码来源:ExcelImportServer.java
示例6: saveImage
import org.apache.poi.ss.usermodel.PictureData; //导入依赖的package包/类
/**
*
* @param object
* @param picId
* @param excelParams
* @param titleString
* @param pictures
* @param params
* @throws Exception
*/
private void saveImage(Object object, String picId, Map<String, ExcelImportEntity> excelParams,
String titleString, Map<String, PictureData> pictures,
ImportParams params) throws Exception {
if (pictures == null) {
return;
}
PictureData image = pictures.get(picId);
if(image == null) {
return;
}
byte[] data = image.getData();
String fileName = "pic" + Math.round(Math.random() * 100000000000L);
fileName += "." + PoiPublicUtil.getFileExtendName(data);
if (excelParams.get(titleString).getSaveType() == 1) {
String path = PoiPublicUtil
.getWebRootPath(getSaveUrl(excelParams.get(titleString), object));
File savefile = new File(path);
if (!savefile.exists()) {
savefile.mkdirs();
}
savefile = new File(path + "/" + fileName);
FileOutputStream fos = new FileOutputStream(savefile);
try {
fos.write(data);
} finally {
IOUtils.closeQuietly(fos);
}
setValues(excelParams.get(titleString), object,
getSaveUrl(excelParams.get(titleString), object) + "/" + fileName);
} else {
setValues(excelParams.get(titleString), object, data);
}
}
开发者ID:rushingpig,项目名称:poix,代码行数:44,代码来源:ExcelImportServer.java
示例7: addListContinue
import org.apache.poi.ss.usermodel.PictureData; //导入依赖的package包/类
/***
* 向List里面继续添加元素
*
* @param exclusions
* @param object
* @param param
* @param row
* @param titlemap
* @param targetId
* @param pictures
* @param params
*/
private void addListContinue(Object object, ExcelCollectionParams param, Row row,
Map<Integer, String> titlemap, String targetId,
Map<String, PictureData> pictures, ImportParams params)
throws Exception {
Collection collection = (Collection) PoiPublicUtil.getMethod(param.getName(),
object.getClass()).invoke(object, new Object[] {});
Object entity = PoiPublicUtil.createObject(param.getType(), targetId);
String picId;
boolean isUsed = false;// 是否需要加上这个对象
for (int i = row.getFirstCellNum(); i < row.getLastCellNum(); i++) {
Cell cell = row.getCell(i);
String titleString = (String) titlemap.get(i);
if (param.getExcelParams().containsKey(titleString)) {
if (param.getExcelParams().get(titleString).getType() == 2) {
picId = row.getRowNum() + "_" + i;
saveImage(object, picId, param.getExcelParams(), titleString, pictures, params);
} else {
saveFieldValue(params, entity, cell, param.getExcelParams(), titleString, row);
}
isUsed = true;
}
}
if (isUsed) {
collection.add(entity);
}
}
开发者ID:xiaolanglang,项目名称:easypoi,代码行数:39,代码来源:ExcelImportServer.java
示例8: saveImage
import org.apache.poi.ss.usermodel.PictureData; //导入依赖的package包/类
/**
*
* @param object
* @param picId
* @param excelParams
* @param titleString
* @param pictures
* @param params
* @throws Exception
*/
private void saveImage(Object object, String picId, Map<String, ExcelImportEntity> excelParams,
String titleString, Map<String, PictureData> pictures,
ImportParams params) throws Exception {
if (pictures == null) {
return;
}
PictureData image = pictures.get(picId);
byte[] data = image.getData();
String fileName = "pic" + Math.round(Math.random() * 100000000000L);
fileName += "." + PoiPublicUtil.getFileExtendName(data);
if (excelParams.get(titleString).getSaveType() == 1) {
String path = PoiPublicUtil.getWebRootPath(getSaveUrl(excelParams.get(titleString),
object));
File savefile = new File(path);
if (!savefile.exists()) {
savefile.mkdirs();
}
savefile = new File(path + "/" + fileName);
FileOutputStream fos = new FileOutputStream(savefile);
fos.write(data);
fos.close();
setValues(excelParams.get(titleString), object,
getSaveUrl(excelParams.get(titleString), object) + "/" + fileName);
} else {
setValues(excelParams.get(titleString), object, data);
}
}
开发者ID:xiaolanglang,项目名称:easypoi,代码行数:38,代码来源:ExcelImportServer.java
示例9: createPicture
import org.apache.poi.ss.usermodel.PictureData; //导入依赖的package包/类
@SneakyThrows
public static String createPicture(PictureData picture) {
if (picture == null) return "null";
val extension = picture.suggestFileExtension();
val imageFileName = String.valueOf(WestId.next()) + "." + extension;
File file = new File(imageFileName);
file.deleteOnExit(); // comment out this for human assertion
@Cleanup val out = new FileOutputStream(file);
out.write(picture.getData());
return imageFileName;
}
开发者ID:bingoohuang,项目名称:excel2javabeans,代码行数:14,代码来源:ImageTest.java
示例10: addPictureInfo
import org.apache.poi.ss.usermodel.PictureData; //导入依赖的package包/类
private void addPictureInfo(ExcelToCanvas ret, PictureData data, int[] p, String border) {
if (this.readRange != null) {
int sx = getColLeft(this.readRange.x);
int sy = getRowTop(this.readRange.y);
p[0] -= sx;
p[1] -= sy;
if (p[0] < 0 || p[1] < 0) {
return;
}
if (p[0] + p[2] > sx + ret.getWidth() || p[1] + p[3] > sy + ret.getHeight()) {
return;
}
}
ret.addPictureInfo(new ExcelToCanvas.PictureInfo(data, p, border));
}
开发者ID:shunjikonishi,项目名称:excel2canvas,代码行数:16,代码来源:ExcelToCanvasBuilder.java
示例11: PictureInfo
import org.apache.poi.ss.usermodel.PictureData; //导入依赖的package包/类
public PictureInfo(PictureData data, int[] p, String border) {
StringBuilder buf = new StringBuilder();
buf.append("data:")
.append(data.getMimeType())
.append(";base64,");
buf.append(Base64.encodeBase64String(data.getData()));
this.uri = buf.toString();
this.p = p;
this.border = border;
this.data = data.getData();
this.mimeType = data.getMimeType();
this.ext = data.suggestFileExtension();
}
开发者ID:shunjikonishi,项目名称:excel2canvas,代码行数:15,代码来源:ExcelToCanvas.java
示例12: ImageAreaInfo
import org.apache.poi.ss.usermodel.PictureData; //导入依赖的package包/类
public ImageAreaInfo(ClientAnchor i_Anchor ,PictureData i_PictureData)
{
this.anchor = i_Anchor;
this.pictureData = i_PictureData;
}
开发者ID:HY-ZhengWei,项目名称:hy.common.report,代码行数:6,代码来源:ImageAreaInfo.java
示例13: getPictureData
import org.apache.poi.ss.usermodel.PictureData; //导入依赖的package包/类
public PictureData getPictureData()
{
return pictureData;
}
开发者ID:HY-ZhengWei,项目名称:hy.common.report,代码行数:5,代码来源:ImageAreaInfo.java
示例14: setPictureData
import org.apache.poi.ss.usermodel.PictureData; //导入依赖的package包/类
public void setPictureData(PictureData pictureData)
{
this.pictureData = pictureData;
}
开发者ID:HY-ZhengWei,项目名称:hy.common.report,代码行数:5,代码来源:ImageAreaInfo.java
示例15: createImageData
import org.apache.poi.ss.usermodel.PictureData; //导入依赖的package包/类
public static ImageData createImageData(PictureData pic) {
return new ImageData(pic.getData(), pic.suggestFileExtension(), pic.getMimeType(), pic.getPictureType());
}
开发者ID:bingoohuang,项目名称:excel2javabeans,代码行数:4,代码来源:ExcelImages.java
示例16: getAllPictures
import org.apache.poi.ss.usermodel.PictureData; //导入依赖的package包/类
/**
* Not supported
*/
@Override
public List<? extends PictureData> getAllPictures() {
throw new UnsupportedOperationException();
}
开发者ID:monitorjbl,项目名称:excel-streaming-reader,代码行数:8,代码来源:StreamingWorkbook.java
注:本文中的org.apache.poi.ss.usermodel.PictureData类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论