import com.smartxls.WorkBook; import java.io.FileOutputStream; public class ReadImageSample { public static void main(String args[]) { try { WorkBook workBook = new WorkBook(); //open the workbook workBook.read("..\\template\\book.xls"); String filename = "img"; int type = workBook.getPictureType(0); if(type == -1) filename += ".gif"; else if(type == 5) filename += ".jpg"; else if(type == 6) filename += ".png"; else if(type == 7) filename += ".bmp"; byte[] imagedata = workBook.getPictureData(0); FileOutputStream fos = new FileOutputStream(filename); fos.write(imagedata); fos.close(); } catch (Exception e) { e.printStackTrace(); } } } import com.smartxls.PictureShape; import com.smartxls.ShapeFormat; import com.smartxls.WorkBook; public class WriteImagesSample { public static void main(String args[]) { try { WorkBook workBook = new WorkBook(); //Inserting image PictureShape pictureShape = workBook.addPicture(1, 0, 3, 8, "..\\template\\MS.GIF"); ShapeFormat shapeFormat = pictureShape.getFormat(); shapeFormat.setPlacementStyle(ShapeFormat.PlacementFreeFloating); pictureShape.setFormat(); workBook.write(".\\pic.xls"); } catch (Exception e) { e.printStackTrace(); } } } //java/1305