2
我試圖使用POI將表導出爲PPT。但是我的表格可以包含n個行。如何在ppt中使用apache POI在多個幻燈片中拆分長表
問題是整個表格顯示在同一張幻燈片中。我想根據行數將幻燈片拆分成不同的幻燈片。
我試圖使用POI將表導出爲PPT。但是我的表格可以包含n個行。如何在ppt中使用apache POI在多個幻燈片中拆分長表
問題是整個表格顯示在同一張幻燈片中。我想根據行數將幻燈片拆分成不同的幻燈片。
我可能會錯過某些東西,但顯而易見的問題是什麼?
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();
}
}
在上面的代碼中,我遇到了一個問題,其中最後一張幻燈片將包含多餘的列。所以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;
}
}