获取图像,并使用Apache POI从Excel文件中的位置 [英] Get an image and its position from excel file using Apache POI
问题描述
是否可以提取使用Apache POI从XLS US preadsheet图像的信息?
Is it possible to extract an image's information from an xls spreadsheet using Apache POI?
在我的一个项目,我需要从一个.xls文件看了一些图片。我可以读取所有图像在一起,但我怎么能得到的图像位置(像列和行号或坐标)?否则,我可以得到图像的位置,但我不知道的信息,如图片名称或分机或他人,在左右发现的位置的具体形象。我怎样才能获得的图像和位置吗?
In one of my projects, I need to read some images from a .xls file. I can read all images together, but how can I get images position (like columns and rows number or coordinates)? Otherwise I can get images position but I can't know information, like picture name or extension or others, about a specific image at the positions found. How I can get images and positions too?
下面阅读所有图片... 这里<一个href=\"http://apache-poi.1045710.n5.nabble.com/A-newbie-question-how-to-get-image-position-td2294815.html\">get图片位置...
推荐答案
看看这里:
http://poi.apache.org/spreadsheet /快guide.html#图片
示例:
List lst = workbook.getAllPictures();
for (Iterator it = lst.iterator(); it.hasNext(); ) {
PictureData pict = (PictureData)it.next();
String ext = pict.suggestFileExtension();
byte[] data = pict.getData();
if (ext.equals("jpeg")) {
FileOutputStream out = new FileOutputStream("pict.jpg");
out.write(data);
out.close();
}
}
这之后,您可以像使用的imageinfo工具延伸难懂找出各种CONFIGS。哟,甚至可以将图像转换为不同的大小。
After this, you can use tools like ImageInfo which extends Magick to find out various configs. Yo can even convert images to different sizes.
看看这个类还有:
http://blog.jaimon.co.uk/simpleimageinfo/SimpleImageInfo。 java.html
- 希望这有助于
这篇关于获取图像,并使用Apache POI从Excel文件中的位置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!