- Requirement: The most recent project needs to move the app's upload menu function to the PC side to achieve, the main difficulty is the image of the bulk import, because the framework is the company's own development, I really dare not compliment, upload files I use JS to the server, in the background to read ....
Why upload to the server, because now the security of the browser is improved, input file cannot get the true absolute address ....
- Jar:poi-3.12.jar Poi-ooxml-3.12.jar Poi-ooxml-schemas-3.8-20120326.jar Xmlbeans-2.3.0.jar No Use the same version because there were some in the project before, I'm lazy, It's a direct, non-conflict use.
- Note: Reading Excel needs to differentiate between 07 and 07 versions, here I only write above 07 (including 07)
- Code:
FileInputStream ins =NewFileInputStream (FilePath); Wookbook=Newxssfworkbook (INS); Ins.close (); List<XSSFPictureData> pictures =wookbook.getallpictures (); for(inti= 0; I < pictures.size (); i++) {Xssfpicturedata PictureData=Pictures.get (i); byte[] data =Picturedata.getdata (); String ext=picturedata.suggestfileextension (); FileOutputStream out=NewFileOutputStream ("C:\\users\\administrator\\desktop\\imanger\\pict" +i+ ".") +ext); Out.write (data); Out.close (); }
- Summary: The picture in the Exel, not the elements in the table, can be understood as floating on the table, cannot be fixed in the table
Java POI read Excel file essay