2011-11-25 89 views

回答

2

我可能會錯過某些東西,但顯而易見的問題是什麼?

Slide slide = hslf.createSlide(); 
int rows = 0; 
int maxRowsPerSlide = 10; // Tune this 

for(MyRowThingy row : getMeMyRows()) { 
    doAddRowToSlide(row, slide); 

    rows++; 
    if(rows % maxRowsPerSlide == 0) { 
     // Slide is full, time for a new slide! 
     slide = hslf.createSlide(); 
    } 
} 
0

在上面的代碼中,我遇到了一個問題,其中最後一張幻燈片將包含多餘的列。所以maxRowsPerSlide必須是dynamic.for我使用folowing功能

public int getMaxRowsInOneSlide(int sizeOfTotalRowsArray, int totalCount){ //totalCount is the count of current row 
    int maxRowsPerSlide = 0; 

    if(sizeOfArray - totalCount >= 10){ //10 is the default rows in a slide 
     maxRowsPerSlide = 10; 
    } 
    else{ 
     maxRowsPerSlide = (sizeOfArray - totalCount)+1;    //'+1' because each slide contains a row for the column names in the table 
    } 
    return maxRowsPerSlide; 
} 
} 
相關問題