src/ca/rmen/pdm/xls2html/main/Xls2Html.java
/**
     * Read the page and poem sheets of an Excel workbook, and return the list of Webpages which are ready to be given to freemarket to generate HTML files.
     */
Read the page and poem sheets of an Excel workbook, and return the list of Webpages which are ready to be given to freemarket to generate HTML files.
Read the page and poem sheets of an Excel workbook and return the list of Webpages which are ready to be given to freemarket to generate HTML files .
private static List<Webpage> readBook(Workbook wb) {
        Map<String, Webpage> documents = readPageMeta(wb);
        Sheet poemSheet = wb.getSheet("poem");
        List<String> columnNames = readColumnNames(poemSheet);
        int rowCount = poemSheet.getRows();
        for (int r = 1; r < rowCount; r++) {
            Map<String, String> values = readRow(poemSheet, r, columnNames);
            String title = values.get(Poem.Column.TITLE.name());
            System.out.println(title);
            String poemTypeName = values.get(Poem.Column.POEM_TYPE.name());
            Poem.PoemType poemType = Poem.PoemType.valueOf(poemTypeName.toUpperCase(Locale.US));
            String pageNumber = values.get(Poem.Column.PAGE_NUMBER.name());
            String poemNumber = values.get(Poem.Column.POEM_NUMBER.name());
            String preContent = values.get(Poem.Column.PRE_CONTENT.name());
            String content = values.get(Poem.Column.CONTENT.name());
            String year = values.get(Poem.Column.YEAR.name());
            String link = values.get(Poem.Column.LINK.name());
            int month = Integer.valueOf(values.get(Poem.Column.MONTH.name()));
            int day = Integer.valueOf(values.get(Poem.Column.DAY.name()));
            String location = values.get(Poem.Column.LOCATION.name());
            String date = day >= 1 ? day + " de " + MONTHS[month - 1] + " de " + year : MONTHS[month - 1] + " de "
                    + year;
            String locationDate = location + ", " + date;
            if(content == null || content.isEmpty())
                continue;
            Webpage webpage = documents.get(pageNumber);
            if(webpage == null) 
                continue;
            switch (poemType) {
            case BREVERIA:
                webpage.addBreveria(new Poem(title, "Brevería", poemNumber, preContent, content, locationDate, date, link));
                break;
            case SONNET:
                webpage.addSonnet(new Poem(title, "Soneto", poemNumber, preContent, content, locationDate, date, link));
                break;
            default:
                webpage.addOtherPoem(new Poem(title, null, poemNumber, preContent, content, locationDate, date, link));
                break;
            }
        }
        final List<Webpage> result = new ArrayList<Webpage>();
        SortedSet<String> pageNumbers = new TreeSet<String>();
        pageNumbers.addAll(documents.keySet());
        for (String pageNumber : pageNumbers)
            result.add(documents.get(pageNumber));
        return result;
    }
private static List < Webpage > readBook ( Workbook wb ) { Map < String , Webpage > documents = readPageMeta ( wb ) ; Sheet poemSheet = wb . getSheet ( "poem" ) ; List < String > columnNames = readColumnNames ( poemSheet ) ; int rowCount = poemSheet . getRows ( ) ; for ( int r = 1 ; r < rowCount ; r ++ ) { Map < String , String > values = readRow ( poemSheet , r , columnNames ) ; String title = values . get ( Poem . Column . TITLE . name ( ) ) ; System . out . println ( title ) ; String poemTypeName = values . get ( Poem . Column . POEM_TYPE . name ( ) ) ; Poem . PoemType poemType = Poem . PoemType . valueOf ( poemTypeName . toUpperCase ( Locale . US ) ) ; String pageNumber = values . get ( Poem . Column . PAGE_NUMBER . name ( ) ) ; String poemNumber = values . get ( Poem . Column . POEM_NUMBER . name ( ) ) ; String preContent = values . get ( Poem . Column . PRE_CONTENT . name ( ) ) ; String content = values . get ( Poem . Column . CONTENT . name ( ) ) ; String year = values . get ( Poem . Column . YEAR . name ( ) ) ; String link = values . get ( Poem . Column . LINK . name ( ) ) ; int month = Integer . valueOf ( values . get ( Poem . Column . MONTH . name ( ) ) ) ; int day = Integer . valueOf ( values . get ( Poem . Column . DAY . name ( ) ) ) ; String location = values . get ( Poem . Column . LOCATION . name ( ) ) ; String date = day >= 1 ? day + " de " + MONTHS [ month - 1 ] + " de " + year : MONTHS [ month - 1 ] + " de " + year ; String locationDate = location + ", " + date ; if ( content == null || content . isEmpty ( ) ) continue ; Webpage webpage = documents . get ( pageNumber ) ; if ( webpage == null ) continue ; switch ( poemType ) { case BREVERIA : webpage . addBreveria ( new Poem ( title , "Brevería", oemNumber, reContent, ontent, ocationDate, ate, ink) ) ; break ; case SONNET : webpage . addSonnet ( new Poem ( title , "Soneto" , poemNumber , preContent , content , locationDate , date , link ) ) ; break ; default : webpage . addOtherPoem ( new Poem ( title , null , poemNumber , preContent , content , locationDate , date , link ) ) ; break ; } } final List < Webpage > result = new ArrayList < Webpage > ( ) ; SortedSet < String > pageNumbers = new TreeSet < String > ( ) ; pageNumbers . addAll ( documents . keySet ( ) ) ; for ( String pageNumber : pageNumbers ) result . add ( documents . get ( pageNumber ) ) ; return result ; }
Read the page and poem sheets of an Excel workbook, and return the list of Webpages which are ready to be given to freemarket to generate HTML files.
Read the page and poem sheets of an Excel workbook and return the list of Webpages which are ready to be given to freemarket to generate HTML files .