Iterator<Row> rowIterator = sheet.rowIterator();//рабочий метод который не совсем подходит 

code from used libraries

  public class XSSFSheet extends POIXMLDocumentPart implements Sheet { ... public Iterator<Row> rowIterator() { return this._rows.values().iterator(); } ... } public class TreeMap<K,V> extends AbstractMap<K,V> implements NavigableMap<K,V>, Cloneable, java.io.Serializable { ... public Collection<V> values() { Collection<V> vs = values; return (vs != null) ? vs : (values = new Values());//нужно переписать эту часть ... } } 

    1 answer 1

    You can create an anonymous class that extends the non-final class you are using and redefines the non-final method in it.

     XSSFSheet sheet = new XSSFSheet(){ //Переопределяйте тут } 
    • and if the sheet object is passed in a method? private void fromExcelToData (XSSFSheet sheet, String p, String f) ' - Ildar
    • @Ildar, it is impossible to override an already created object. You need to either find the place where it is created and redefine it there or not use it, but write your own class with the necessary methods and use it. - JuriySPb