java - Swapped images while extracting from excel using JavaScript -


my problem while extracting images in excel using java script images swapped somewhere.[![enter image description here][1]][1]

using java code here

a94 row -- saving picture94
a95 row -- saving picture95
a96 row -- saving picture96

i want save bellow formate

a94 row -- saving picture94
a95 row -- saving picture96
a96 row -- saving picture95

i want save each images respective cell. please give me idea .do have change java code.
code

import java.io.fileinputstream; import java.io.fileoutputstream; import java.io.ioexception; import java.io.inputstream; import java.util.iterator;  import java.util.list;  import org.apache.poi.hssf.usermodel.hssfcell; import org.apache.poi.hssf.usermodel.hssfrow; import org.apache.poi.hssf.usermodel.hssfsheet; import org.apache.poi.hssf.usermodel.hssfworkbook;  import org.apache.poi.ss.usermodel.picturedata;  public class readwriteexcelfile1 {      public static void readxlsfile() throws ioexception     {         inputstream excelfiletoread = new fileinputstream("e://eclips//excelextract1.xls");         hssfworkbook wb = new hssfworkbook(excelfiletoread);          hssfsheet sheet=wb.getsheetat(0);         hssfrow row;          hssfcell cell;          iterator rows = sheet.rowiterator();          ///         row=(hssfrow) rows.next();         list lst = wb.getallpictures();         int i=1;         (iterator = lst.iterator(); it.hasnext(); ) {             picturedata pict = (picturedata)it.next();             string ext = pict.suggestfileextension();             byte[] data = pict.getdata();             if (ext.equals("jpeg") || ext.equals("jpg") || ext.equals("png")) {                 row=(hssfrow) rows.next();                 iterator cells = row.celliterator();                 cell=(hssfcell) cells.next();                 //if(i<=100)                 //{                 system.out.print("==>"+cell.getstringcellvalue()+" == "+cell.getstringcellvalue()+"."+ext+"\n");                 system.out.println(row);               fileoutputstream out = new fileoutputstream("e://eclips//output//"+cell.getstringcellvalue()+"."+ext);               out.write(data);               out.close();                 //}               i++;                 //}               //if(i>=101){              //   break;               //}             }         }        }     public static void main(string[] args) throws ioexception {              readxlsfile();         system.out.println("export completed");     } } 

pictures not assigned cells directly. related cells via clientanchor. list returned workbook.getallpictures() not sorted , not have relation actual cell.

you should able @ information via drawing class , drawingpatriarch of sheet in workbook:

drawing drawing = sheet.createdrawingpatriarch(); for(hssfshape shape : ((hssfpatriarch)drawing).getchildren()) {     if(shape instanceof hssfpicture) {         hssfclientanchor anchor = ((hssfpicture)shape).getclientanchor();         ... anchor has cell-row/column area "anchored" @     } } 

Comments

Popular posts from this blog

php - Wordpress website dashboard page or post editor content is not showing but front end data is showing properly -

How to get the ip address of VM and use it to configure SSH connection dynamically in Ansible -

javascript - Get parameter of GET request -