简体   繁体   中英

How to read blob from excel sheet in extjs

I have a excel sheet which contains multiple columns with data along with a column which contains file paths. When I upload it to extjs grid, I want to read blob data based on the file path column before it's submitted to a database. I don't have a form, I need to get data when clicking on a submit button from the grid. How can we read local system data from an excel sheet. I have tried to read the image at the backed (using java spring) but it's reading as if client and server both exits in single system. I want to read the blob from client side. How can I do it in java. Please give some suggestion.

PFA

private static void GetShapePosition(HttpServletRequest request) {

  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();
  } 

}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM