Wednesday, April 18, 2012

itext filling table

I need to fill a table with in the first column a number and in the second column certain data from a array.



So it will look like :



1 | Data1



2 | Data2



3 | Data3



What is the best way to add this data.



Usualy you do something like :



 Table table = new Table(3); 
table.setWidth(100);
table.setDefaultVerticalAlignment(Element.ALIGN_TOP);
table.setCellsFitPage(true);
table.setPadding(2);
table.setSpacing(0);
for (int i = 1; i <= 6; i++) {
Cell cell = new Cell("Data " + i);
table.addCell(cell); }


Then you get something like :



Data 1 | Data 2 | Data 3



Data 4 | Data 5 | Data 6



Is there a specific way to fill selected cells or do I see it wrong.





No comments:

Post a Comment