プライベートの静的な無効GetShapePosition(HttpServletRequestのリクエスト){
try {
InputStream inp = new FileInputStream("D:/SVN_PROJECTS/WorkDevServer/EnrollSample.xls");
Workbook wb = WorkbookFactory.create(inp);
HSSFSheet sheet = (HSSFSheet)wb.getSheetAt(0);
HashMap<String,byte[]> hashMap = new HashMap<String,byte[]>();
HSSFPatriarch dravingPatriarch = sheet.getDrawingPatriarch();
java.util.List<HSSFShape> shapes = dravingPatriarch.getChildren();
for (HSSFShape shape : shapes) {
if (shape instanceof HSSFPicture) {
HSSFPicture hssfPicture = (HSSFPicture)shape;
int picIndex = hssfPicture.getPictureIndex();
String filename = hssfPicture.getFileName();
HSSFPictureData hssfPictureData = hssfPicture.getPictureData();
byte[] b = hssfPictureData.getData();
String s= hssfPictureData.getMimeType();
HSSFClientAnchor hca = hssfPicture.getPreferredSize();
System.out.println(" row : -> "+(hca.getRow1())+" column : -> "+(hca.getCol1()));
hashMap.put(String.valueOf((hca.getRow1()))+String.valueOf((hca.getCol1())),b);
}
}
request.getSession().setAttribute("ImghashMap", hashMap);
} catch (Exception e) {
e.printStackTrace();
}
}
あなたの答え – Mazz
getDrawingPatriarchを(教えてください)我々はすべての画像を一覧表示することができるからHSSFPatriarchにオブジェクトを提供しますgetChildren()メソッドの助けを借りてシートを秀でる。そこから位置やバイトなどの画像の詳細を取得できます。imagename、mimeType – sangamesh