本文整理汇总了Java中org.apache.poi.ss.usermodel.PictureData.getData方法的典型用法代码示例。如果您正苦于以下问题:Java PictureData.getData方法的具体用法?Java PictureData.getData怎么用?Java PictureData.getData使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.poi.ss.usermodel.PictureData
的用法示例。
在下文中一共展示了PictureData.getData方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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);
}
}
示例2: 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);
}
}
示例3: 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();
}
示例4: 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());
}