static IDataModel toDataModel(final Workbook workbook) {
        if (workbook == null) { return null; }
        
        //add custom functions information
        workbook.addToolPack(getUdfFinder());
        
        Sheet s = workbook.getSheetAt(0); //TODO: only one sheet is supported
        if (s == null) { return null; }
        
        IDataModel dm = new DataModel(s.getSheetName());
        
        for (int i = s.getFirstRowNum(); i <= s.getLastRowNum(); i++) {
            Row r = s.getRow(i);
            if (r == null) { continue; }
            
            DmRow row = new DmRow(i);
            dm.setRow(i, row);
            
            for (int j = r.getFirstCellNum(); j < r.getLastCellNum(); j++) {
                Cell c = r.getCell(j);
                if (c == null) { continue; }
                
                DmCell cell = new DmCell();
                row.setCell(j, cell);
                
                cell.setAddress(new CellAddress(dm.getDataModelId(), A1Address.fromRowColumn(i, j)));
                cell.setContent(ConverterUtils.resolveCellValue(c));
            }
        }

        EvaluationWorkbook evaluationWbook = ConverterUtils.newEvaluationWorkbook(workbook);

        for (int nIdx = 0; nIdx < workbook.getNumberOfNames(); nIdx++) {
            Name name = workbook.getNameAt(nIdx);

            String reference = name.getRefersToFormula();
            if (reference == null) { continue; }

            if (A1Address.isAddress(removeSheetFromNameRef(reference))) {
                dm.setNamedAddress(name.getNameName(), A1Address.fromA1Address(removeSheetFromNameRef(reference)));
            } else if (isFormula(reference, evaluationWbook)) {
                dm.setNamedValue(name.getNameName(), new CellValue(FORMULA_PREFIX + reference));
            } else {
                dm.setNamedValue(name.getNameName(), CellValue.from(reference));
            }
        }

        return dm;
    }
static IDataModel toDataModel ( final Workbook workbook ) { if ( workbook == null ) { return null ; } workbook . addToolPack ( getUdfFinder ( ) ) ; Sheet s = workbook . getSheetAt ( 0 ) ; if ( s == null ) { return null ; } IDataModel dm = new DataModel ( s . getSheetName ( ) ) ; for ( int i = s . getFirstRowNum ( ) ; i <= s . getLastRowNum ( ) ; i ++ ) { Row r = s . getRow ( i ) ; if ( r == null ) { continue ; } DmRow row = new DmRow ( i ) ; dm . setRow ( i , row ) ; for ( int j = r . getFirstCellNum ( ) ; j < r . getLastCellNum ( ) ; j ++ ) { Cell c = r . getCell ( j ) ; if ( c == null ) { continue ; } DmCell cell = new DmCell ( ) ; row . setCell ( j , cell ) ; cell . setAddress ( new CellAddress ( dm . getDataModelId ( ) , A1Address . fromRowColumn ( i , j ) ) ) ; cell . setContent ( ConverterUtils . resolveCellValue ( c ) ) ; } } EvaluationWorkbook evaluationWbook = ConverterUtils . newEvaluationWorkbook ( workbook ) ; for ( int nIdx = 0 ; nIdx < workbook . getNumberOfNames ( ) ; nIdx ++ ) { Name name = workbook . getNameAt ( nIdx ) ; String reference = name . getRefersToFormula ( ) ; if ( reference == null ) { continue ; } if ( A1Address . isAddress ( removeSheetFromNameRef ( reference ) ) ) { dm . setNamedAddress ( name . getNameName ( ) , A1Address . fromA1Address ( removeSheetFromNameRef ( reference ) ) ) ; } else if ( isFormula ( reference , evaluationWbook ) ) { dm . setNamedValue ( name . getNameName ( ) , new CellValue ( FORMULA_PREFIX + reference ) ) ; } else { dm . setNamedValue ( name . getNameName ( ) , CellValue . from ( reference ) ) ; } } return dm ; }
For given {@link Workbook} does convert everything to new {@link DataModel} structure.
Does copy all supported fields (for supported fields see {@link DataModel} class.