2015-01-05 27 views

回答

2

您可以通過使用PdfCell數組做到這一點:

ncols = 6; // number of columns 
nrows = 8; // number of rows 
Pdfcell[][] cells = new PdfCell[nrows][ncols]; 

// To create the table cells 
for(int icol=0; icol<ncols; icol++) { 
    for(int irow=0; irow<nrows; irow++) { 
     cells[irow][icol] = new PdfCell(new Phrase(
       "Col:" + icol + ", Row:" + irow)); 
    } 
} 

// To add the cells to table 
for(int irow=0; irow<nrows; irow++) { 
    for(int icol=0; icol<ncols; icol++) { 
     table.addCell(cells[irow][icol]); 
    } 
} 
相關問題