All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.swiftboot.sheet.excel.HSSFPictureAdapter Maven / Gradle / Ivy

There is a newer version: 2.4.7
Show newest version
package org.swiftboot.sheet.excel;

import org.apache.poi.hssf.usermodel.*;
import org.apache.poi.ss.usermodel.Picture;
import org.apache.poi.ss.usermodel.Sheet;
import org.swiftboot.sheet.meta.Position;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @author allen
 */
public class HSSFPictureAdapter implements PictureAdapter {

    @Override
    public Map getPictures(Sheet sheet) {
        Map ret = new HashMap<>();
        HSSFSheet hssfSheet = (HSSFSheet) sheet;
        List children = hssfSheet.getDrawingPatriarch().getChildren();
        for (HSSFShape child : children) {
            HSSFClientAnchor anchor = (HSSFClientAnchor) child.getAnchor();
            HSSFPicture p = (HSSFPicture) child;
            ret.put(new Position(anchor.getRow1(), (int) anchor.getCol1()), p);
        }
        return ret;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy